Principios SOLID aplicados al Frontend con REACT. Documentación basada en https://www.youtube.com/watch?v=jKdt-BnTTR0&ab_channel=midulive Topics react typescript study frontend solid solid-principles midudev
Originally introduced by Robert C. Martin (aka Uncle Bob) for object-oriented programming, SOLID principles help developers write scalable, maintainable, and robust software. While JavaScript’s dynamic nature doesn’t always align with traditional OOP paradigms, React’s component-based architecture mak...
例如下面的react代码,我们经常看到组件负责太多事情——例如管理UI和业务逻辑。 代码语言:javascript 代码运行次数:0 运行 AI代码解释 functionUserProfile({userId}){const[user,setUser]=useState(null);useEffect(()=>{fetchUserData();},[userId]);asyncfunctionfetchUserData(){constresponse=awaitfetch(`/api/...
Applying SOLID principles in React 几乎是对上述文章的直接回答,即使SOLID的应用在这里被更广泛地覆盖(components + hooks)。注意:不要犹豫,使用React上下文进行依赖注入。 拓展阅读 Avoid anonymous components with displayName: sometimes React can't infer a good name for your components, which complicates the...
把这六个原则的首字母联合起来(两个 L 算做一个)就是 SOLID (solid,稳定的),其代表的含义就是这六个原则结合使用的好处:建立稳定、灵活、健壮的设计。下面我们来分别看一下这六大设计原则。 单一职责原则(SRP) 单一功能原则 :单一功能原则 认为对象应该仅具有一种单一功能的概念。
react中经常提及的木偶组件(dump component)其实和文章中第一部分的例子如出一辙 工厂模式和命令模式也一定程度体现了单一职责原则,前者对于作为生产者存在并不需要关心消费者如何消费对象实例,后者以命令的方式封装功能本身就是单一职责原则的体现。 我能够想到的就这么多,写的比较乱,抛砖引玉,如有错误,还望指正。
SOLID principles in C# SOLID design principles in C# are basic design principles. SOLID stands for Single Responsibility Principle (SRP), Open closed Principle (OSP), Liskov substitution Principle (LSP), Interface Segregation Principle (ISP), and Dependency Inversion Principle (DIP). Basics of ...
There is always room for improving one’s coding ability, and SOLID design principles offer one way to see marked improvements in final output. With SOLID P...
React S.O.L.I.D Principles for writing clean-code SRP: Single Responsibility Principle OCP: Open-Closed Principle LSP: Liskov Substitution Principle ISP: Interface Segregation Principle DIP: Dependency Inversion Principle All the principles are explained on CoderOne's youtube channel: https://youtu...
A class, a module, or a function should be only responsible for one actor. So, it should have one and only one reason to change. The single responsibility principle is one of SOLID’s simplest principles. However, developers often misinterpret it, thinking a module should do a single thing...