34 ms·
But despite not using it every day, you'd probably be able to refresh on it pretty quickly. I've found that to be the real value for a lot of the courses I too
by kevmo314 6y ago
But despite not using it every day, you'd probably be able to refresh on it pretty quickly.
I've found that to be the real value for a lot of the courses I took. Sure, I don't actively remember the content or use it daily, but occasionally something reminds me of something I learned. Then, it's a quick wiki page away from me understanding and using it. Contrast that with some devs I've worked with who haven't seen such things before and end up reinventing a less elegant solution to the problem.
- atum47 6y agoon the interview for the job I have right now, they asked me a lot about design patterns. I took a class on that and implemented a lot of them in Java. Factory, Facade, Visitor, Singleton... Never used them again after college, ask me about it, I think I would be able to explain Factory and Singleton from the top of my head, the rest... gone!!! I guess what I'm trying to say is that I would love to be that guy with a lot of information in the head, that can casually drop statics formulas and math concepts in a conversation, but that's not the case for my. At least for a lot of topics. Watching the videos made me think about that. Starting a live video and answering 240 questions on several topics likes it's no big deal. Haha
- valuearb 6y agoYou never use a Factory or Singleton? That’s weird to me cause I use them daily. But certainly Singletons can also be problematic, especially if you do automated testing, which I do not.
- zelphirkalt 6y agoThat's probably because of the use of different paradigms. If you write typical so called OOP code all the time, sure, you'll hit many instances of this or that pattern coming in handy. If you write FP and only occasionally strew in some OOP, well, many of the patterns fly out of the window, as you do not really need then any longer, because the building block is a function and you solve most of the stuff using closures and higher order functions. Also you usually do not mutate state, so that is another load of patterns out of the window. Surely however, it is good to know the patterns approximately well, so that you can quickly understand the meaning of code, which makes use of them. If only all people used design patterns always in a correct way, instead of implementing them half-way correct and then using them in a weird way ... Never hurts too look up the details again, before introducing a pattern into the code!
- chopin 6y agoIf I can, I never use the classical singleton pattern because of testability. On the other hand I use one single instance of a class if I can make use of a dependency injection framework. I prefer that over static classes which have the bad habit of getting in the way of testing.
- btilly 6y agoThe use case for a Singleton is that you want to use a global variable but don't want to admit that you are using a global variable.
- AnimalMuppet 6y agoHere's an embedded system. It has a hardware resource. There's only one such hardware resource. A singleton to manage it is a natural. I suppose you could argue that it's still a global variable, but I think it's more fundamental than that. You use a singleton when there should be exactly one of something. Why is there exactly one? "Because there's only one in the hardware" is a fundamentally different answer than "because it's a global variable".
- btilly 6y agoA singleton only seems natural to you because you are used to using them. Other programmers might reach for a global variable or a static variable for the same purpose in the same situation. The tradeoffs are pretty subtle. However, as I said, the main reason that I have seen singletons used is programmers who heard lectures about how bad global variables are, heard about global variables, and didn't understand that every argument against a global variable also applies to a singleton.
- dodobirdlord 6y agoNot entirely true, because a singleton can implement defensive logic and maintain coordination state that is difficult with a global variable. For something like a unique hardware resource a singleton that administrates the resource can do things like enforce queueing on components that want to communicate with the hardware resource, and make decisions about which components to notify when the resource responds.
- btilly 6y agoI said subtle, not non-existent. For example you tout the advantages of enforced access rules. And indeed enforcement is good for avoiding bugs from accidental concurrent access. But said enforcement also means that bugs in releasing access at the proper time are harder to recover from. I've seen systems fail both ways, and it is unclear to me which one is better. (For example I've had more problems with Windows enforcing locking in its filesystem than with bugs in Unix's advisory only locking policy.)
- projektfu 6y agoFacade, well, that’s obvious from the name. It’s not just an OO pattern. Visitor is a hack. You need to traverse an opaque structure but you know the types of its nodes. A simple lambda in other languages, it’s needed in (older) C++ and Java because of the single dispatch method calls. Even so, it’s not common in languages that rely on runtime typing or algebraic data types.