Code Refactoring 9

[ad_1]
Get the Code:

In this part of my code refactoring tutorial I will cover how to turn an implied tree structure into a composite pattern.

What do you do when you want to model a tree structure? You can either list the info as primitives and then search through them for what you want or you can create objects that represent each level of the tree with the composite pattern.


Posted

in

by

Tags:

Comments

24 responses to “Code Refactoring 9”

  1. zack android Avatar

    When would I used a Tree(Data Structure) rather than the Composite(Design Pattern)? It seems to me like they both store data in a hierarchical way.

  2. Brax1982 Avatar

    Anyone else not able to watch this? It's not loading. The rest of this series is fine.

  3. Nikolai Kalashnikov Avatar

    Derek, can you do a video on RX ? Netflix has said that they have refactored their code to RX and they saw enormous improvements in performance. I've also read that it's easier to multi-thread. So maybe you can do a video on using an RX Pipeline API and also building an RX API back-end.

    I can only find information on using the pipeline… Which takes about 5 seconds to understand… But I would like to see the "big picture" too… What the back-end looks like. Probably mostly fields that are interfaces, i'm guessing. I think you could distill it down into the important parts so that we can understand it.

  4. Nikolai Kalashnikov Avatar

    Finally, Components! This looks very extensible for adding new components to a system. Thanks!

  5. Rob L Avatar

    Why do you do all of the casting??? Isn't the array list of type ProductComponent already?

  6. Derek Banas Avatar

    Thank you very much 🙂 Im very appreciative that you watched my video

  7. suhas seenappa Avatar

    Thank you for taking time to explain all this concepts. You're doing a wonderful job.

  8. Derek Banas Avatar

    Thank you very much 🙂 Thanks for the nice comment! I very much appreciate it

  9. Derek Banas Avatar

    Thank you for pointing that out. I try to keep things understandable rather than optimized in these videos. Your idea is great though 🙂

  10. syzer Avatar

    Awesome tutorial!, One remark: u can make add() return instance of Product, so u can remove call remove() on pointer to this instance.

  11. Mladen Uzelac Avatar

    Eclipse IDE supports code templates. 😉

  12. Mladen Uzelac Avatar

    Eclipse is defacto standard IDE in Java world and is also extensible.

  13. Mladen Uzelac Avatar

    Eclipse support code templates 😀
    I always write main, Ctrl+Space and Enter.
    Code templates are also customizeable. B-)

  14. Truthiness231 Avatar

    Ah, was going to say "shame there aren't more open source IDEs for devs to add what they want when they want to", but then just to make sure that was correct I googled it and found that NetBeans is open source! It's not my favorite but all things considered I'll have to consider it next time I need some considerable automation from my IDE. ^.^

  15. Derek Banas Avatar

    Sure I can do that. I pretty much did it in the OOD tutorial, but I'll cover it specifically

  16. Damith Chathuranga Avatar

    great tut series. Could please explain SOLID concept in the future. 🙂

  17. Derek Banas Avatar

    I'd love to make my own IDE. There are numerous tools I'd implement.

  18. Derek Banas Avatar

    It calls for the execution of the superclasses constructor. Does that make sense?

  19. Truthiness231 Avatar

    Someone needs to suggest to the IDE devs that there should be some shortcut templates built for "add" and "remove" when making a class that handles a list; might seem silly to some, but I've had to write those two functions (and a few others like "insertAt" and "removeAt", for example) about a 1000 times (way more than one should have). Might be that the IDEs I use just haven't thought of it, but can't remember seeing them in any I've ever used…

  20. seemsas Avatar

    I really love your tuts.
    As Im not from java: can you briefly explain, what the super() method does?

  21. 123japanuser Avatar

    主席先生,

    我黄金 🙂

  22. Derek Banas Avatar

    ನಾನು ನಾಳೆ ಮತ್ತೊಂದು ವೀಡಿಯೊ ಅಪ್ಲೋಡ್ ಮಾಡಲು ನನ್ನ ಕೈಲಾದ ಎಷ್ಟು ಬೆಳ್ಳಿ ಪದಕಗಳನ್ನು ನೀವು 🙂 ಹೊಂದಿರುತ್ತವೆ ಅದ್ಭುತ ಹೊಂದಿದೆ.

  23. 123japanuser Avatar

    ಹಾಯ್ ಕೋಚ್,

    ಈ ವೀಡಿಯೊ ಅನೇಕ ಅನೇಕ ಧನ್ಯವಾದಗಳು.

    ನಿಮ್ಮ ಉದಾರತೆ ಕಾರಣ ನನ್ನ ಜ್ಞಾನ ಸೇರಿಸುವುದು.

    ನಾನು ತುಂಬ ಕೆಲಸ ತನ್ನ ಖಚಿತವಾಗಿ ನಾನು ಮತ್ತು ನೀವು ನಮಗೆ ದೊಡ್ಡ ಪರವಾಗಿ ಮಾಡುತ್ತಿದ್ದಾರೆ.

    ಆರೈಕೆಯನ್ನು
    ಬೆಳ್ಳಿ ಪದಕ ವಿಜೇತ.

  24. Derek Banas Avatar

    I'm doing my best to make a video a day 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *