State pattern (TypeScript Design Patterns)

  Рет қаралды 23,512

Simply Explained

Simply Explained

Күн бұрын

Пікірлер: 50
@reveryoungfo
@reveryoungfo 6 жыл бұрын
Hi, are you going to continue this series? :D I think there are more patterns and you explain them in the right way! Thanks
@sarthaksahu117
@sarthaksahu117 4 жыл бұрын
Please make videos on more patterns! It is very easy to remember these patterns with the examples you are giving. Thanks!
@creative-commons-videos
@creative-commons-videos 4 жыл бұрын
Doesn't Circular Dependencies count as a bad practice ? where we require State in Order and Order in State ?
@troglokev
@troglokev 6 жыл бұрын
There’s a bit of a code smell here, in that the interface is forcing the implementation of methods for operations that don’t exist in the state diagram.
@estranhokonsta
@estranhokonsta 5 жыл бұрын
Not really. The state diagram just show what is 'legal' to do. This pattern strength is that it can react intelligently to any possible transitions, legal or not. It doesn't make assumptions about the capacity of the UI or API to not allow illegal state transitions.
@ChristopherOkhravi
@ChristopherOkhravi 7 жыл бұрын
Great idea to exemplify Design Patterns in TypeScript! Subbed 😀
@Cognitoman
@Cognitoman 5 жыл бұрын
ohh shit guess who it is :)
@amitpattjoshi
@amitpattjoshi 4 жыл бұрын
@@Cognitoman just watched chris video to get the basic clear and your example just helped me to clarify further if any doubt I had. But dont agree with instanciating all concrete states in constructor seems redundent.
@hangchen6131
@hangchen6131 7 жыл бұрын
That's a great design pattern tutorial, also can be applied to all programming languages generally.
@TheZoreslav
@TheZoreslav 5 жыл бұрын
The best explaining of pattern in js
@willl0014
@willl0014 4 жыл бұрын
Very well explained sir, and excellent example selection.
@vooose
@vooose 7 жыл бұрын
great series of videos please keep them going
@simplyexplained
@simplyexplained 7 жыл бұрын
Thanks! Any patterns in particular that you would like to see explained?
@vooose
@vooose 7 жыл бұрын
@Savjee I just came across these videos to learn more about TS (rather than design patterns per se) but I find the practical examples easier to learn from than videos specifically about TS language features (tho your other series on TS I still found most useful) - not exactly a design pattern but perhaps a video on TDD (or just unit testing) with TS would be helpful
@narendratechguy7140
@narendratechguy7140 7 жыл бұрын
Why did you stopped developing this series, please complete it
@simplyexplained
@simplyexplained 7 жыл бұрын
+narendra techguy any patterns you would like to see?
@narendratechguy7140
@narendratechguy7140 7 жыл бұрын
Savjee all the patterns that are in GoF
@MrEnsiferum77
@MrEnsiferum77 5 жыл бұрын
This is bad implementation of the state pattern, the Order class, does not need to know how to create the classes who implement the state interface and also u breaking open-close principle. Also, classes who implements the state interface, are bound to particular class in this case Order. U need DI with interface, so u can swap Order class in future.
@ojuliomiguel
@ojuliomiguel 4 жыл бұрын
Do you have this code example with this improvements?
@avimehenwal
@avimehenwal 3 жыл бұрын
Totally agree (Y)
@avimehenwal
@avimehenwal 3 жыл бұрын
Are getters and setters required in this case? I see the class attribute is already set to public at 2:30, i am thinking when property could be directly accessed and changed from outside why have getters and setters? Do they provide any additional value which I might have overlooked? Super thanks for answering my query :)
@simplyexplained
@simplyexplained 3 жыл бұрын
Getters and setters are mainly used to allow you to change underlying structure of your classes without affecting your application itself. Setters are also useful to do validation before accepting values in your application.
@avimehenwal
@avimehenwal 3 жыл бұрын
@@simplyexplained when you say validations that makes sense. Still why have public class attributes then? Doesn't take make the attribute insecure !!! ? We can directly change it from outside using className.attribute = "new value" Doesn't that defeat the purpose of getters and setters in the first place?
@simplyexplained
@simplyexplained 3 жыл бұрын
Oops, yes, they should've been private! This is often a requirement in companies to not have any public attributes.
@avimehenwal
@avimehenwal 3 жыл бұрын
@@simplyexplained Thanks for the closure :) Have a great day
@SportAnalysisKing
@SportAnalysisKing 7 жыл бұрын
I really liked your explanation on StatePattern it was very clear and concise. I would love to see how you implement complex if and else with Rule pattern and Decorator pattern to do logging or anything with decorator but to see logging would be nice
@ayushpratap4726
@ayushpratap4726 5 жыл бұрын
HI Savjee! Really liked all your design patterns videos for typescript! Would really appreciate if you will add more videos to the series! waiting for a very long time ! Please make videos on GANG OF FOUR design Patterns in typescript!
@gbkEmilgbk
@gbkEmilgbk Ай бұрын
what about circular references? Order uses CacneledOrderState, CanceledOrderState use Order - ?
@SibyAugustine93
@SibyAugustine93 7 жыл бұрын
Brilliant tutorial... And if we want to add some other states in future how will we do that? without disturbing current system.
@dmytrosamburskyi1022
@dmytrosamburskyi1022 7 жыл бұрын
You are doing great videos. But I have a remark, you don't keep object's properties encapsulated. In most places 'public' properties should be 'private', especially when you have getter and setter or pass an object into constructor. Though the series is about design patterns, it's showing bad habit pattern :)
@simplyexplained
@simplyexplained 7 жыл бұрын
You are 100% right and I normally don't make that mistake. Damn it! Thanks for letting me know. I'll put a warning up in the description!
@okragula
@okragula 6 жыл бұрын
Thanks for the great series, you’ve helped me a lot. I have to ask though (at least what to google for), in the ‘Order state: ‘ log statement, what is the use of in that particular case (I understand that any means of any type, I’ve never seen it used like that.)
@pathakvivek7865
@pathakvivek7865 3 жыл бұрын
Please make such videos of other patterns too..
@9324981
@9324981 7 жыл бұрын
Nice series.
@fieldset3689
@fieldset3689 5 жыл бұрын
Why using an state Interface instead of a state Class ?
@DanielMunoz-bn6gk
@DanielMunoz-bn6gk 6 жыл бұрын
Hi, excellent video. I need you help, i try this pattern with angular 6 but not working, get this error: "Converting circular structure to JSON". I think this is because order have a State field and the state have a order field. Do you know how to solve this problem?
@cedrics7374
@cedrics7374 5 жыл бұрын
Hi Daniel, did you find a solution yet? I was planning on using on an Angular 8 project
@ngneerin
@ngneerin 3 жыл бұрын
Isn't this against DRY principle
@aeromina
@aeromina 6 жыл бұрын
Thank you so much for these videos :)
@awsguide2912
@awsguide2912 4 жыл бұрын
Thank You a Lot !!
@AmxCsifier
@AmxCsifier 7 жыл бұрын
brilliant stuff
@tervancovan
@tervancovan Жыл бұрын
this is what I want
@buchdev
@buchdev Жыл бұрын
Why did you used any on line 123? Oh God! you're using typescript, use a type, please
@NulledExp
@NulledExp Жыл бұрын
uff some big cycles around, please ffs TELL DONT ASK / LoD? :( I know this video is about State pattern but this can be super dangerous when you try to show how to implement design patterns when u burn the whole base of Design, PLEASE
@AlbertoRivas13
@AlbertoRivas13 4 жыл бұрын
This guys doenst have the text editor in dark mode, dislike
@angelhdzdev
@angelhdzdev 2 жыл бұрын
This guys doesn't appreciate the amount of free and clear information provided, but complains about colors, dislike
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 903 М.
The State Design Pattern in Python Explained
19:14
ArjanCodes
Рет қаралды 79 М.
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Session | 004 | Networking Fundamentals
2:04:27
Cloud World
Рет қаралды 2
Observer (TypeScript Design Patterns)
12:10
Simply Explained
Рет қаралды 29 М.
Command Pattern - Design Patterns
14:49
Web Dev Simplified
Рет қаралды 101 М.
Javascript Design Patterns #6 - Proxy Pattern
12:11
DevSage
Рет қаралды 28 М.
Refactoring a React component - Design Patterns
15:19
Cosden Solutions
Рет қаралды 101 М.
Prototype Pattern in JavaScript
14:49
Code with Ahsan
Рет қаралды 2,6 М.
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,4 МЛН
Design Patterns in Angular Source Code - Strategy Design Pattern
12:48
Decoded Frontend
Рет қаралды 18 М.
Decorator Design Pattern
12:57
Derek Banas
Рет қаралды 428 М.
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН