Follow this principle for BETTER code 👩‍💻 #code #coding #technology #programmer #programming

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

me pretending to know what this is as a game developer:

Steelxfaze
Автор

It is good advice but can spiral into chaos very fast if you overapplied it

ДеянДелчев-ыз
Автор

Great, now I have hundreds of classes and I just wanted a linear designed program

eaxEA
Автор

Functions and classes are overpowered. Change my mind.

NBZ
Автор

That feels like Java Mentality and I don’t embrace it. Everyone should decide for themselves when a new class is needed and not create classes each time their original ones were multi-purpose. Otherwise chaos and One-Instance-Classes are unavoidable

raumi_
Автор

Your attention to detail and dedication to your craft is truly inspiring. Thank you for sharing your expertise with us!🖤❣

MyCodingDiary
Автор

I like to follow srp to an extent, but i also think there are instances where it becomes overkill. I usually make functions and classes that have only a few related responsibilities in those cases. Usually this is when that piece of functionality isnt going to be used in more than one place and is highly specific to one use case

xXWarPotatoXx
Автор

That neon Background is blinding my precious dark mode eyes

worksonweekends
Автор

Question one: What is the second thing the class is doing, other than keeping age and grade info?

Question two: Why don't we implement an AgeBook class?

ugurunver
Автор

No. Single Responsibility is not for functions. Is for modules to have a single responsibility in terms of business logic.

laughingvampire
Автор

I have a way of making your code 100 times better when doing object oriented code, don't do object oriented code. Use c++, but only use it in a c style way.

skeleton_craftGaming
Автор

I don't think a short does this justice.
Single responsibility really is answering the question, if there is a change to be made, there should only be one source of the change because there should only be one place of truth (logic or data). So if you are making a class called EmployeePayments and it, PrintsPayslips, CalculatesPay and ManagesPayees this violates it because Legal, Accounting and Database departments all have interests in the logic and data. The reason it exists is to pay the employees but because so many other people have investments in the logic it is responsible for the requirements of more than one need making changes harder (cannot imagine how long the tests would be for such a thing).

ScottGarryFoster
Автор

This is the best ti pI'v ever came across.GOOD GUY

divyasnhundley
Автор

What are you taking about Lewis?

We all know that we can cramp and compress all our code forming a singularity. I call it "Singularity principle".

This helps in dropping only 1 file when it doesn't work so I can focus more on the crying part.

thcpuhr
Автор

In object oriented programming we optimize, reuse and maintain the code by following the SOLID principle.

SOLID is an acronym for five design principles that help in writing
maintainable and scalable code. These principles are widely used in
object-oriented programming and can be applied to Java as well. Let's
briefly explain each principle:

1. Single Responsibility Principle (SRP): A class should have only one
reason to change. It means that a class should have only one
responsibility or a single job to do. This principle promotes high
cohesion and ensures that a class has a clear and focused purpose.

2. Open/Closed Principle (OCP): Software entities (classes, modules,
functions) should be open for extension but closed for modification. It
means that you should be able to add new functionality without
modifying existing code. This principle promotes code reuse and
minimizes the impact of changes.

3. Liskov Substitution Principle (LSP): Subtypes must be substitutable
for their base types. It means that objects of a superclass should be
able to be replaced with objects of its subclass without affecting the
correctness of the program. This principle ensures the correct behavior
of polymorphism.

4. Interface Segregation Principle (ISP): Clients should not be forced to
depend on interfaces they do not use. It means that a class should not
be forced to implement unnecessary methods from an interface. This
The principle promotes interface granularity and avoids fat interfaces.

5. Dependency Inversion Principle (DIP): High-level modules should not
depends on low-level modules. Both should depend on abstractions. It
means that classes should depend on abstractions (interfaces or
abstract classes) rather than concrete implementations. This principle
promotes loose coupling and improves testability.

vitthal
Автор

I get the whole single responsibility idea, but in this case I don’t see anything wrong with adding grade as another member variable for the student.

kevinwoodrobotics
Автор

I'm a .NET developer, and I like to use SRP, and really divide that complex problem in as little pieces as I can. Knowing I can then easily change anything anywhere along the way just warms my heart.

But I have to say, I'm kinda lazy, so my absolute favourite is DRY - Don't Repeat Yourself. I'm still a beginner, and this principle was good practice for learning how to work with generic types, from usage in other classes to dependency injection.
As a bonus, I also had to familiarize myself with delegates, specifically Func, for transmitting context appropriate LINQ between app layers.

longbow
Автор

Another: When doing object oriented code, really consider if you actually need to write object oriented code.

JoshLathamTutorials
Автор

A quiete easy to understand and implement principle from solid.

oliveryt
Автор

Something that I would love would be to have a small conversation with you. For example, you could take an hour or two per week when you go live and then randomly pick people on your list to give them 5 minutes or less to ask questions. For example, I want to build something and just getting specific advice from you would be incredibly helpful. Perhaps I don't know something and just need to push in the right direction. I guess I could also write a few paragraphs on what I am doing and ask for advise too.

jessefry
welcome to shbcf.ru