Abstraction Vs Code Readability

Поделиться
HTML-код
  • Опубликовано: 28 ноя 2024

Комментарии • 43

  • @JackPunter2012
    @JackPunter2012 3 дня назад +31

    Saying that without abstraction you have to duplicate the greet logic "over and over again" is a complete disservice to other paradigms. Your right absolutely noone in they're right mind would do that... But functions exist for a reason. Inheritance isn't the only solution to these problems and videos like this, imo, do a bad job at demonstrating the options, new programmers will see this and agree with what's being said (which isn't wrong) but they'll take away that abstraction is the mechanism to solve this problem. When In A lot of cases alternatives are better suited.

    • @kantancoding
      @kantancoding  День назад +5

      Name one alternative or paradigm that doesn’t involve abstraction…
      I think your misunderstanding comes from the fact that you think inheritance is the only form of abstraction when in fact, it is not.
      Those “other paradigms” that you speak of likely also use abstraction.
      And just because I’m using inheritance in the example, it doesn’t mean that I am saying that inheritance is the only solution.
      I’m not talking about ‘inheritance’ specifically. I’m talking about abstraction, which includes but is not limited to inheritance.

    • @sp3ctum
      @sp3ctum День назад +1

      @@kantancoding yes, exactly. Also, I think what is being talked about here is polymorphism, inheritance being one way to implement it. I think the subject is complex and the video does a great job at demonstrating it.

    • @kantancoding
      @kantancoding  14 часов назад

      @sp3ctum Good point! The sad part is, most beginners/juniors won’t read further into this thread. They will just agree with what op said even though it’s ill-informed 🤷‍♂️

    • @Nellak2011
      @Nellak2011 3 часа назад

      @@kantancoding Bro just use an explicit mapping and in the mapping you can refer to functions or data. It is not that hard.

  • @Qbe_Root
    @Qbe_Root День назад +3

    Basically, just make sure your interfaces make sense, and document them well, so no one has to look for the actual implementation just to understand the intent. And know when it's not worth the hassle to do all that

  • @wjrasmussen666
    @wjrasmussen666 3 дня назад +11

    What does the fox say?

  • @d2teisen
    @d2teisen 3 дня назад +6

    Just don't pre-abstract everything, pre-mature abstraction is root of all evil 🤔

  • @dcmbassi
    @dcmbassi 3 дня назад +10

    My takeaway is that stampeding buffalo are just saying hello.

  • @Nellak2011
    @Nellak2011 3 часа назад

    Here is a simplification of my map based approach if the previous comment was confusing.
    ---
    const animalBehaviors = {
    dog: {
    greet: () => console.log("Woof!"),
    eat: () => console.log("Dog food time!"),
    },
    cat: {
    greet: () => console.log("Meow!"),
    eat: () => console.log("Cat food time!"),
    },
    bird: {
    greet: () => console.log("Tweet tweet!"),
    eat: () => console.log("Bird seed time!"),
    },
    }
    const performAction = (animal, action) => animalBehaviors[animal][action]()
    performAction('dog', 'greet') // Output: Woof!
    performAction('cat', 'eat') // Output: Cat food time!
    ----
    There is no need for inheritance, no boilerplate classes, and this is highly extensible.
    Yet it provides the same level of abstraction as the OOP approach.

  • @danielg4681
    @danielg4681 3 дня назад +4

    To abstract or not abstract is a hard question
    I would just base it off of the single responsibility principal
    As soon a function or service has more than one reason to change, it should be abstracted
    Just my opinion tho!

    • @greyshopleskin2315
      @greyshopleskin2315 3 дня назад +1

      Do you know this principle is related to stakeholders and not technical reasons?

    • @danielg4681
      @danielg4681 3 дня назад +1

      @ how so? Like company departments?

    • @greyshopleskin2315
      @greyshopleskin2315 3 дня назад

      @@danielg4681 read clean architecture book, there’s a chapter for that

    • @greyshopleskin2315
      @greyshopleskin2315 3 дня назад

      @@danielg4681 but yeah, sort of

  • @nangz
    @nangz 3 дня назад +7

    A good example might also be when an animal's greeting is individually more complex.
    Say, an animal that has a different greeting based on its gender or age.
    Or when the greeting is more complex than just a sound, say the greet() performs other actions like wag() or jump().

  • @rilauats
    @rilauats 3 дня назад +1

    You're right, abstraction is good when it helps us develop and maintain code. Like abstraction is good to obtain simplicity in many other areas of our daily life. Like instruction chart for your next flat box furniture - or - cooking recipe for your next dinner. They all use abstraction.

  • @byaruhaf
    @byaruhaf 3 дня назад +2

    LOL, ending the video with the classic software developer response: "It depends."

  • @eispider
    @eispider 17 часов назад

    What theam are you using in intellij ? it looks nice.

  • @SirusStarTV
    @SirusStarTV 2 дня назад +1

    Of course you can get rid of abstraction on your own project when it's your source code, but when you're using libraries you don't have a choice.

  • @enchantedplays7860
    @enchantedplays7860 3 дня назад +1

    I like this no bloat and sharing your opinion and ideas

  • @TheBypasser
    @TheBypasser 12 часов назад

    Lol just figured it was Java xD Because you said using a map is wrong, but that is what I normally do in C: a constant array of structures containing the function and resource pointers as well as, if needed, a literal name (say, it is a command a user can either run from a console or get a description of).

  • @Nellak2011
    @Nellak2011 3 часа назад

    The problem isn't Abstraction, it is improper abstraction using OOP bullshit.
    You can make things abstract in an intuitive way.
    --- Ex:
    import Heading from 'whereever you made it'
    const headersData = [{ text: 'example header' }]
    const componentMap = { Heading }
    const dataMap = { 'Heading' : headersData }
    const layout = [
    {
    data: [{ titleComponent: 'Heading', titleContent: 0 }] // refer to the pre-made Heading component and fill it with the 0th thing in that list
    }
    ]
    const mapper = layout.map(section => (
    { ... map through it the way you need }
    ))
    ----
    In the above example, I made an abstraction that makes it to where you can define both the Component and Data Content for a page by simply swapping out references to it in the data part.
    The data part has no need to know about the details about the functions or components you use, only what they are called.
    So therefore, the component that uses this will not need to know "how" only "what".
    --- Component using it (Example)
    export const AboutPageBody = ({ state }) => {
    const { body } = state || {}
    return (

    {body?.map(bodySectionData =>

    {bodySectionData?.data?.map(titledComponentData => )}

    )}

    )
    }
    -------
    The AboutPageBody component acts as a very compressed component. It doesn't need to know the details or really dictate many things, it just reads from what it is given.
    It is an Abstraction since it says "what" instead of "how", but it isn't complicated since all you have to do to debug it is to visit the data file with the explicit mappings and adjust the specific components and other functions you use to map it.
    The complexity is bounded to at most 2 hops instead of the implicit bindings used in OOP.
    The advantage of this approach is that now we can scale up our sites dramatically by supplying Data rather than hard-coded websites.

  • @werneryc
    @werneryc 2 дня назад +4

    You don't program a lot do you?

  • @rodrigoribeiro8476
    @rodrigoribeiro8476 2 дня назад +1

    sorry to bother, but what is the font used in the code?

  • @avidrucker
    @avidrucker 19 часов назад

    Isn't this an example of polymorphism rather than abstraction? Or are you using the term "abstraction" more in the general, broad, "doing OOP" sense (as opposed to procedural)? The term doesn't seem to be clearly defined here

    • @kantancoding
      @kantancoding  14 часов назад

      I don’t think the phrase “polymorphism rather than abstraction” makes sense since polymorphism is inherently abstraction.

  • @nngnnadas
    @nngnnadas 7 часов назад

    just give every species a "sound" variable and use it. Are you trying to write dataless code or something?

  • @SirusStarTV
    @SirusStarTV 2 дня назад

    When learning materials explain the concepts behind OOP through some Animal analogy, amateur programmers could be confused "why tf we need to create classes for animals?!?"

  • @ult1873
    @ult1873 3 дня назад +1

    Well, I mean, what a table can't do, a switch statement can. So it's fine ¯\_(ツ)_/¯

  • @mvargasmoran
    @mvargasmoran День назад

    Bruh there's nothing that I dislike more than "Class Oriented Programming" I don't have much problem with Objects, but Classes... ooof.

  • @GordonRoland
    @GordonRoland 2 дня назад

    As illustrated: Different solutions for for different situations. Only disagreement with you: Not "Abstraction Vs Readability." Abstraction can be most readable solution.

  • @pajeetsingh
    @pajeetsingh 3 дня назад +2

    Depends on the person.
    Some people are good at following orders and some can't stop asking why.

  • @venusearth6682
    @venusearth6682 3 дня назад +1

    I hope you have an amazing Thanksgiving ♥️♥️♥️♥️❣️❣️❣️

  • @NachtmahrNebenan
    @NachtmahrNebenan 3 дня назад

    Plus, try to avoid "else" and "else if". Just return the greet. Do it like NASA🚀

    • @derstreber2
      @derstreber2 3 дня назад

      NASA has a much harder stance on recursion. Recursion is banned. Never use recursion!

  • @omegand.
    @omegand. 3 дня назад

    0:08 just goto implementation instead of definition and problem solved tbh

  • @RadenVijaya
    @RadenVijaya 11 часов назад

    Why dont you use switch / case?