Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. How do I decide for class responsibilities?

How do I decide for class responsibilities?

Scheduled Pinned Locked Moved Java
tutorialquestiondesignbusinessarchitecture
30 Posts 9 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Neo10101

    Excuse me? I come from a university with one of the highest reputations there are. We program and work the qualitative way. This isn't one semester. It's my graduate year. I'm actually going to be an Application Developer. There's only so far you can get with 'practice' and 'experience'. Fundamental concepts and methods are far more important. That's why the top engineers get higher ranked without doing the work. Didn't you ever learn that? The tons of math and logic theory I had to process before I came to this point. The years of lectures on Software Engineering. Never underestimate the importance of scholar theory.

    N Offline
    N Offline
    Nagy Vilmos
    wrote on last edited by
    #6

    Dear boy, I have been there already. FYI, I recently did another degree course - exactly to get an update on the academic theory - and noun/verbal extraction is still a very valid and useful exercise. When, or if, you work professionally, you will understand that there is so much within the problem domain that impacts how classes are decided upon. Experience is the dog's doo-dahs in deciding how to break down a problem domain to find candidate classes.


    Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

    1 Reply Last reply
    0
    • N Neo10101

      Excuse me? I come from a university with one of the highest reputations there are. We program and work the qualitative way. This isn't one semester. It's my graduate year. I'm actually going to be an Application Developer. There's only so far you can get with 'practice' and 'experience'. Fundamental concepts and methods are far more important. That's why the top engineers get higher ranked without doing the work. Didn't you ever learn that? The tons of math and logic theory I had to process before I came to this point. The years of lectures on Software Engineering. Never underestimate the importance of scholar theory.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #7

      CsTreval wrote:

      I come from a university with one of the highest reputations there are.

      Soon to be lowest.

      CsTreval wrote:

      I'm actually going to be an Application Developer.

      With this attitude you are bound to go far.

      speaking as ...

      N 1 Reply Last reply
      0
      • N Neo10101

        Excuse me? I come from a university with one of the highest reputations there are. We program and work the qualitative way. This isn't one semester. It's my graduate year. I'm actually going to be an Application Developer. There's only so far you can get with 'practice' and 'experience'. Fundamental concepts and methods are far more important. That's why the top engineers get higher ranked without doing the work. Didn't you ever learn that? The tons of math and logic theory I had to process before I came to this point. The years of lectures on Software Engineering. Never underestimate the importance of scholar theory.

        S Offline
        S Offline
        Stingrae789
        wrote on last edited by
        #8

        My graduate university is ranked among the lowest in England, even they taught us that even with experience there is always more to learn. Education is great but never tie yourself to it, what works in theory doesn't always apply to every situation. In industry experience is worth more atleast until you actually have had a few jobs. Software development is the one field where a specific degree doesn't necessarily make you better than Joe Bloggs who self-taught. Also experience > actual software developed > education as far as I can see Also lose the idea that top people get paid to do practically nothing you will find that even some CEOs work over 9 hours a day, design and planning may be what they (top engineers) actually get paid for but that still involves thinking and much of that comes as the result of experience.

        N 1 Reply Last reply
        0
        • S Stingrae789

          My graduate university is ranked among the lowest in England, even they taught us that even with experience there is always more to learn. Education is great but never tie yourself to it, what works in theory doesn't always apply to every situation. In industry experience is worth more atleast until you actually have had a few jobs. Software development is the one field where a specific degree doesn't necessarily make you better than Joe Bloggs who self-taught. Also experience > actual software developed > education as far as I can see Also lose the idea that top people get paid to do practically nothing you will find that even some CEOs work over 9 hours a day, design and planning may be what they (top engineers) actually get paid for but that still involves thinking and much of that comes as the result of experience.

          N Offline
          N Offline
          Neo10101
          wrote on last edited by
          #9

          Right. At your university they never taught you in the advanced English class about the Dilbert principle? This happens in real life too, you know? Hence the principle. I know some people who get paid very highly and I chat with them for about 50% of the time I'm taking lectures. What does this imply? Well, it implies that they are sitting on their chair all day being lazy and getting paid huge salaries (because I know his function). It used to be that the really hard working and intelligent people were bumped up to manager. Now it's the other way around. If you really believe that hard working smart people get the better salaries, you're wrong. I've experienced nothing like it in the real world. I've worked before as well. I've been programming on a 3 month contract in a company my university suggested. The programmers were just absolutely horrible and cynical people. They were also not very bright. I knew more about programming and computers than they did. Anyway not to drift off the point here. Experience certainly may help in the IT industry of today, but if it wasn't for my university's high reputation (because they have excellent courses and professors) I wouldn't even have had the slightest chance to function as a temporary programmer in a company. I tried before. You have no idea how many 'no' answers I got. Meanwhile, a top paid programmer I know who works for one of the best software development companies can only type with two fingers and can't even do a copy paste in Excel! How fair is that?! Yes, what a world. With hard work you get somewhere.. please.

          D N J P 4 Replies Last reply
          0
          • N Neo10101

            Right. At your university they never taught you in the advanced English class about the Dilbert principle? This happens in real life too, you know? Hence the principle. I know some people who get paid very highly and I chat with them for about 50% of the time I'm taking lectures. What does this imply? Well, it implies that they are sitting on their chair all day being lazy and getting paid huge salaries (because I know his function). It used to be that the really hard working and intelligent people were bumped up to manager. Now it's the other way around. If you really believe that hard working smart people get the better salaries, you're wrong. I've experienced nothing like it in the real world. I've worked before as well. I've been programming on a 3 month contract in a company my university suggested. The programmers were just absolutely horrible and cynical people. They were also not very bright. I knew more about programming and computers than they did. Anyway not to drift off the point here. Experience certainly may help in the IT industry of today, but if it wasn't for my university's high reputation (because they have excellent courses and professors) I wouldn't even have had the slightest chance to function as a temporary programmer in a company. I tried before. You have no idea how many 'no' answers I got. Meanwhile, a top paid programmer I know who works for one of the best software development companies can only type with two fingers and can't even do a copy paste in Excel! How fair is that?! Yes, what a world. With hard work you get somewhere.. please.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #10

            Wow. That was a bunch of useless, meaningless crap. Did they also teach you, in your exalted university, that your final year is where you demonstrate that you can apply the techniques and information you've been fed over the last 3 years? If you're asking this question now, it seems that you're in a bit of trouble.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            1 Reply Last reply
            0
            • N Neo10101

              How do I decide what types to make and what responsibilities to give them, given a design concept? Should I base myself on user stories/functional requirements in order to decide which responsibilities my classes need? It's not easy to adhere to the SOLID principle. For example I have this.. 'make a blog' assignment. I wrote down one of those functional requirements: "a blog entry has to have a title and a body". Does that mean I have to write a class Post with members Body and Title? Should a Post (BlogEntry) class only have a body and the title is supposed to be the responsibility of another class? Kind of confusing. There must be a set of rules that tell programmers how to decide on which objects to make and what responsibilities and implementation to give them. Any ideas on this? Thanks

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #11

              It is confusing if you concentrate on one item to the exclusion of all else. Take your example; you have a statement that "a blog entry has to have a title and a body". Okay, I can see where you are going with that, but you're now wondering whether or not you violate SOLID to have a body element AND a title element. This is designing in isolation. You need to consider the other requirements to see what effect they have. For instance, suppose you have a requirement that states that a title must have more than 20 characters and less than 150 characters. Does this mean that you need to create a separate Title class which encapsulates the rules, or do you make it part of the BlogEntry class? Well, that depends - you might want to create a separate validation engine which is responsible for enforcing the rules, in which case you would probably just use attributes on your BlogEntry properties, so the mechanism for defining HOW to validate the properties is external, but the rules for each element are attached (this is a common technique). Then you need to consider where your rules are applied. Do you do everything in your UI, or do you abstract to a business rules class? Is your BlogEntry class actually a model instead? Should you use MVC? The thing I'm trying to get at here is that there is no "one size fits all" solution. As others have said, it's experience, but it is also a case that your start and end point has to be "what do I need to put in to satisfy the requirements?" By all means, consider the use cases - a well architected use case should be a vital part of developing your application because it should tell you how the user will actually use your application. Beyond that, adhering to SOLID is a mix of experience and common sense, and you shouldn't slavishly adhere to something just because someone else has written about how good it is.

              *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

              "Mind bleach! Send me mind bleach!" - Nagy Vilmos

              CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

              N 1 Reply Last reply
              0
              • P Pete OHanlon

                It is confusing if you concentrate on one item to the exclusion of all else. Take your example; you have a statement that "a blog entry has to have a title and a body". Okay, I can see where you are going with that, but you're now wondering whether or not you violate SOLID to have a body element AND a title element. This is designing in isolation. You need to consider the other requirements to see what effect they have. For instance, suppose you have a requirement that states that a title must have more than 20 characters and less than 150 characters. Does this mean that you need to create a separate Title class which encapsulates the rules, or do you make it part of the BlogEntry class? Well, that depends - you might want to create a separate validation engine which is responsible for enforcing the rules, in which case you would probably just use attributes on your BlogEntry properties, so the mechanism for defining HOW to validate the properties is external, but the rules for each element are attached (this is a common technique). Then you need to consider where your rules are applied. Do you do everything in your UI, or do you abstract to a business rules class? Is your BlogEntry class actually a model instead? Should you use MVC? The thing I'm trying to get at here is that there is no "one size fits all" solution. As others have said, it's experience, but it is also a case that your start and end point has to be "what do I need to put in to satisfy the requirements?" By all means, consider the use cases - a well architected use case should be a vital part of developing your application because it should tell you how the user will actually use your application. Beyond that, adhering to SOLID is a mix of experience and common sense, and you shouldn't slavishly adhere to something just because someone else has written about how good it is.

                *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                N Offline
                N Offline
                Nagy Vilmos
                wrote on last edited by
                #12

                Intelligence without being a third year undergraduate! How the fock did you do that?


                Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                P 1 Reply Last reply
                0
                • N Neo10101

                  Right. At your university they never taught you in the advanced English class about the Dilbert principle? This happens in real life too, you know? Hence the principle. I know some people who get paid very highly and I chat with them for about 50% of the time I'm taking lectures. What does this imply? Well, it implies that they are sitting on their chair all day being lazy and getting paid huge salaries (because I know his function). It used to be that the really hard working and intelligent people were bumped up to manager. Now it's the other way around. If you really believe that hard working smart people get the better salaries, you're wrong. I've experienced nothing like it in the real world. I've worked before as well. I've been programming on a 3 month contract in a company my university suggested. The programmers were just absolutely horrible and cynical people. They were also not very bright. I knew more about programming and computers than they did. Anyway not to drift off the point here. Experience certainly may help in the IT industry of today, but if it wasn't for my university's high reputation (because they have excellent courses and professors) I wouldn't even have had the slightest chance to function as a temporary programmer in a company. I tried before. You have no idea how many 'no' answers I got. Meanwhile, a top paid programmer I know who works for one of the best software development companies can only type with two fingers and can't even do a copy paste in Excel! How fair is that?! Yes, what a world. With hard work you get somewhere.. please.

                  N Offline
                  N Offline
                  Nagy Vilmos
                  wrote on last edited by
                  #13

                  Did your super duper university not teach you what a paragraph is? Legibility. Learn the word and learn it quickly!


                  Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    CsTreval wrote:

                    I come from a university with one of the highest reputations there are.

                    Soon to be lowest.

                    CsTreval wrote:

                    I'm actually going to be an Application Developer.

                    With this attitude you are bound to go far.

                    speaking as ...

                    N Offline
                    N Offline
                    Nagy Vilmos
                    wrote on last edited by
                    #14

                    Undergraduates are so sweet when they think they know things.


                    Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                    1 Reply Last reply
                    0
                    • N Nagy Vilmos

                      Intelligence without being a third year undergraduate! How the fock did you do that?


                      Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #15

                      I probably knicked it from someone clever. And I'm someone who hasn't got a computer degree - largely self taught. I don't think it's done me any harm.

                      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                      N 1 Reply Last reply
                      0
                      • P Pete OHanlon

                        I probably knicked it from someone clever. And I'm someone who hasn't got a computer degree - largely self taught. I don't think it's done me any harm.

                        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                        N Offline
                        N Offline
                        Nagy Vilmos
                        wrote on last edited by
                        #16

                        I got my 'putin' degree only last year - after 25+ years - to find out what's new. Very little is the answer.


                        Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                        P 1 Reply Last reply
                        0
                        • N Nagy Vilmos

                          I got my 'putin' degree only last year - after 25+ years - to find out what's new. Very little is the answer.


                          Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                          P Offline
                          P Offline
                          Pete OHanlon
                          wrote on last edited by
                          #17

                          I believe most of it is just fancy names for what we were doing anyway.

                          *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                          N 1 Reply Last reply
                          0
                          • N Nagy Vilmos

                            Did your super duper university not teach you what a paragraph is? Legibility. Learn the word and learn it quickly!


                            Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #18

                            He didn't actually say what the University's reputation was for, just that it was the highest.

                            speaking as ...

                            N 1 Reply Last reply
                            0
                            • P Pete OHanlon

                              I believe most of it is just fancy names for what we were doing anyway.

                              *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                              "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                              CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                              N Offline
                              N Offline
                              Nagy Vilmos
                              wrote on last edited by
                              #19

                              The one thing I found fascinating was Systems Theory[^]. It has nothing to do what you think and is a complete mind fock until you get the little light come on...


                              Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                              P 1 Reply Last reply
                              0
                              • L Lost User

                                He didn't actually say what the University's reputation was for, just that it was the highest.

                                speaking as ...

                                N Offline
                                N Offline
                                Nagy Vilmos
                                wrote on last edited by
                                #20

                                Top for arrests? Absenteeism? We may never know... :-D


                                Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                L 1 Reply Last reply
                                0
                                • N Nagy Vilmos

                                  The one thing I found fascinating was Systems Theory[^]. It has nothing to do what you think and is a complete mind fock until you get the little light come on...


                                  Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                  P Offline
                                  P Offline
                                  Pete OHanlon
                                  wrote on last edited by
                                  #21

                                  That looks interesting. I might do some digging around into that.

                                  *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                  "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                  CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                                  N 1 Reply Last reply
                                  0
                                  • P Pete OHanlon

                                    That looks interesting. I might do some digging around into that.

                                    *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                    "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                    CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                                    N Offline
                                    N Offline
                                    Nagy Vilmos
                                    wrote on last edited by
                                    #22

                                    It's fun when you look at a problem domain and actually find that the best solution is to not use computers but to go back to a manual solution. The simplest description is that you look for a single small step to improve the situation, then go back and repeat until you reach an acceptable situation without knowing what the solution will eb when you start. As I said, it's brain fick to start with until you have an epiphany.


                                    Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                    1 Reply Last reply
                                    0
                                    • N Nagy Vilmos

                                      Top for arrests? Absenteeism? We may never know... :-D


                                      Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #23

                                      We should be told; time for a judicial inquiry.

                                      speaking as ...

                                      N 1 Reply Last reply
                                      0
                                      • L Lost User

                                        We should be told; time for a judicial inquiry.

                                        speaking as ...

                                        N Offline
                                        N Offline
                                        Nagy Vilmos
                                        wrote on last edited by
                                        #24

                                        Nah. Let's just have a witch hunt.


                                        Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                                        1 Reply Last reply
                                        0
                                        • N Neo10101

                                          How do I decide what types to make and what responsibilities to give them, given a design concept? Should I base myself on user stories/functional requirements in order to decide which responsibilities my classes need? It's not easy to adhere to the SOLID principle. For example I have this.. 'make a blog' assignment. I wrote down one of those functional requirements: "a blog entry has to have a title and a body". Does that mean I have to write a class Post with members Body and Title? Should a Post (BlogEntry) class only have a body and the title is supposed to be the responsibility of another class? Kind of confusing. There must be a set of rules that tell programmers how to decide on which objects to make and what responsibilities and implementation to give them. Any ideas on this? Thanks

                                          S Offline
                                          S Offline
                                          Stingrae789
                                          wrote on last edited by
                                          #25

                                          Now to actually give you an alternate answer... While this is overly complicated for the question: Body and Title could be considered types of text components and your Post could be a 'Base Object' type that consists of a component list. In this 'silly' system, your 'Post' can easily be given any number of components because Post supports having components that have their own functions. Why not have the components as members? Well because with this idea of base objects having a list you only have to change whether you are giving the component to the object rather than modifying the member in the class. e.g. I want a new 'StupidEnemy' that has a different 'AIComponent' to the 'Enemy'. I don't have to have a new class for my new type of enemy I simply give them a different AIComponent at instantiation. I don't think this is a great approach in most cases (As you 'could' end up using a data structure to hold a single component, this seems illogical), I’ve used it a little before and it has its pros and cons but it does mean your code fits SOLID. It works quite well for game development though as it keeps the project tidy (Relative to just using straight composition).

                                          //This is all just to represent the use of a components
                                          BaseObject post = new Post(); //for some reason our post needs to be a subclass, again this is just a silly example.
                                          TextComponent Header = new Header("Header"); //Best to use a uID here instead so you can potentially have multiple headers or a multimap over a vector
                                          post.Add(Header); //Add would initialise the component to have a pointer to the Base Object
                                          Post->getComponent("Header").SetMessage("Hello World") //get our component
                                          //in event cycle
                                          Post->Execute();//what ever you want to call on all components Update(), Render() etc.

                                          /rant I didn't do English at University, it has no real place in a BSc also it's more of a sociology/business idea and while it does occur, I want to aim to have a better work ethic constantly for myself!/endrant

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups