General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
TheEvertw
ArjanCodes
comments
Comments by "TheEvertw" (@TheEvertw) on "ArjanCodes" channel.
Previous
1
Next
...
All
"Dependency injection", as explained here, is probably the most simple OO design pattern. In OO, it is called the Strategy Pattern. You hide the details of an algorithm behind an (abstract) interface. The user of the strategy only knows the abstract interface, each implementation of the Strategy interface knows only the details it needs. I don't understand why people wanted to change the name. The name "Strategy Pattern" has been in wide-spread use for 30 years. I guess people like re-inventing the wheel. That is no critique on Arjan, he didn't coin "dependency injection". I thank him for this video, I never understood what people meant with DI. I thought it was some complex trick like the "Curiously Recurring Template" pattern. Which is similar to DI but achieves lightning fast execution & minimal memory footprint, at the cost of long compile times.
7
When handling default arguments, I often use the following line to set them at runtime: `timestamp = timestamp or time.time()` This works if the default value is `None`, because `None` is a "False" value and a valid timestamp is a `True` value. It also uses the fact that Python passes on the actual value of the first `True` element in an `or` operation, and does not evaluate the second value if the first one is already `True`. If the first value is `False`, it yields the second value regardless of whether it is `True` or `False`.
6
Seconded. I spotted that as well, you beat me to it. Besides using the factory argument, Python has the Optional typing hint, which expects a None default value.
4
I LOVE Rust. I also LOVE Python. And I think the two complement each other marvelously. It is very easy to write Python modules in Rust.
4
And you burn CPU cycles.
3
Templates separate the String from the code used to render it. They make it easier to imagine how a rendered document is going look, than having dozens of f-strings sprinkled throughout one or more code files. If you just want a single prompt, an f-string is fine. If you want a document generated from a data set, use Jinja2 (or another templating engine, like Mako or Django).
3
If it ain't broke, don't fix it. But there are uses for these specialized db's.
3
A heavy, review-intensive process gives a false sense of control to Management. But reviews are worth nothing when the team is building something that the end users are not satisfied with. As someone said (Dick Hamming), "it is better to solve the right problem the wrong way than the wrong problem the right way". That makes Continuous Delivery a far superior way of keeping the project on track than a heavy process. To illustrate, I recently witnessed a project that had a pretty heavy process, with lots of reviews. But the project needed a very costly re-design one year into it, because while it was required to support 1500 I/O points, it only managed to support one tenth of that. Testing on hardware proved the software to not be fit for purpose.
2
Jinja2 is great when you can re-use your special formatting over several templates. It is a bit restrictive but that makes writing correct templates easier. I use templates a lot for code generation, where the templates have almost no overlap, meaning there is very little re-use of special formatting filters. In that case, Mako is more powerful. But Mako is harder to debug.
2
Any design pattern is a combination of 4 (sometimes more) classes doing something together. The description of the context makes a design pattern useful. Personally, I consider the UoW pattern a merge of the Command and the Decorator patterns. Any queuing feature is not part of the actual pattern, though real implementation will usually have queuing as well. Like most real implementations of the Command Pattern also have queuing, but it is not part of the pattern itself.
2
While I agree with your analysis, this does display a callous disregard by Crowdstrike of the wellbeing of their customers. I expect they will be sued into oblivion.
2
When I give my kids instructions to do something, I hate it when I check on them half an hour later to find them doing something else because "they couldn't xyz". I'd MUCH rather have them come to me after 5 minutes and ask for help.
1
"In Python you don't have to worry about memory management at all" That is not completely true. Circular references between objects can still cause memory leaks, that is why weakref exists.
1
"This leads to better design" This is EXACTLY why I think that Rust has a great future in store. Rust is the first significant innovation in programming languages in three decades, after the invention of the object-oriented paradigm. OK, support for co-operative multi-tasking through `async` functions was also a significant innovation. But Rust has revolutionized type systems and memory models, which I think is a bigger innovation, and definitely of greater importance for the future of programming.
1
I prefer SMTP as my email sender. Works every time, regardless of how a customer has configured his email server.
1
@dynamicgrad3820 If you pass an empty list as default argument in a function, that default empty list is created once, and then reused every time that function is called. Which means that most likely, after that first function call, that list no longer is empty. And if the list passed to the function is stored somewhere in your code, there are multiple references to that list spread around your data structure waiting to cause nasty and hard-to-debug side-effects. Your Python IDE will warn about this. A better solution is to use an `typing.Optional[List[xxx]]` argument, with a `None` as default argument. `None` is immutable, so it can be safely reused and shared between multiple calls to the function.
1
@dynamicgrad3820 He used a construct that is a common source of nasty bugs in Python: he defined a function with a default argument that is potentially mutable. In Python, there is only one instance of that default argument. When the function is called, the exact same default argument instance is used, which means that it contains the results of whatever the previous function call did to it, and not the pristine clean object you would expect.
1
@dane2565 There are zero guarantees that MailChimp does not store internal state that can not be copied between sessions, now or in the future. So even in this case, it is a definite NO-NO.
1
The delayed print is not Python-specific. That buffering behaviour is standard for all programming languages I know of. Because for most situations, the overhead of printing is huge, and the program only wants to incur this overhead when it is useful to the user. I.e. when a sentence is completed.
1
There are a lot of people who think JavaScript (of all languages) is better than Python because it is faster. That is such a load of cr@p. As the UNIX gurus knew, "Programmer time is expensive. Computer time is cheap." So I will consider a language that makes me more productive as a programmer far superior compared to a language that runs my code a bit faster. Note that this maxim is from the seventies. Compared to back then, computer time has become many orders of magnitude cheaper, and programmer time quite a bit more expensive. And while Python is from a later age and not quite a scripting language, scripting languages were invented by the UNIX people for exactly this reason.
1
Dave Farley of @ContinuousDelivery has some interesting opinions on that. His idea is to never do pull requests, and just let anyone push their work into the main dev branch whenever they feel comfortable the task is complete. While initially shocked, I agree with his reasoning.
1
@AhmedIsam You check them out because they are cool. And you should use technology only after you have checked it out.
1
I have done some work with Influxdb for storing & retrieving measurement data from a sensor network, but the others are new to me. Great introduction!
1
Familiarity with the customer domain is a critical success factor for a software project. It is the job of the Architect / Product Owner to explain the various concepts to all programmers working on the project so that they all get an understanding for them. This will help them interpret stories, design tests, and design the structure and functionality of the software. Without that understanding, there will be loads of booboo moments where they misinterpret what the customer wants.
1
In some languages, you ALWAYS create getters and setters for data members, because of the pain that will be incurred when you change the underlying data structures and / or add algorithms. In Python, this is absolutely not necessary. If at some point you decide that accessing an attribute needs to be replaced with a function call, in Python you can make the attribute a `property`.
1
Previous
1
Next
...
All