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. Design and Architecture
  4. code organisation

code organisation

Scheduled Pinned Locked Moved Design and Architecture
c++
19 Posts 10 Posters 53 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.
  • C Offline
    C Offline
    Calin Negru
    wrote on last edited by
    #1

    Looking at a large project and trying to figure out how it all works I realized that unlike real life software projects don`t have superstructures. It`s all rather scattered/fragmented. Code files have links to other pieces of code via the header files present at the begging of each cpp file and that`s about it.

    B L Greg UtasG J 4 Replies Last reply
    0
    • C Calin Negru

      Looking at a large project and trying to figure out how it all works I realized that unlike real life software projects don`t have superstructures. It`s all rather scattered/fragmented. Code files have links to other pieces of code via the header files present at the begging of each cpp file and that`s about it.

      B Offline
      B Offline
      Bohdan Stupak
      wrote on last edited by
      #2

      I've seen code files with couple of thousand lines and I must say that there is luckily no megastructures as such file are quite complex to reason about, support and put them under test

      M V 2 Replies Last reply
      0
      • C Calin Negru

        Looking at a large project and trying to figure out how it all works I realized that unlike real life software projects don`t have superstructures. It`s all rather scattered/fragmented. Code files have links to other pieces of code via the header files present at the begging of each cpp file and that`s about it.

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

        CalinNegru wrote:

        software projects don`t have superstructures.

        If they a re poorly managed that is generally true. But a well organised project will always have a lot of structure.

        C M 2 Replies Last reply
        0
        • C Calin Negru

          Looking at a large project and trying to figure out how it all works I realized that unlike real life software projects don`t have superstructures. It`s all rather scattered/fragmented. Code files have links to other pieces of code via the header files present at the begging of each cpp file and that`s about it.

          Greg UtasG Offline
          Greg UtasG Offline
          Greg Utas
          wrote on last edited by
          #4

          Some projects are as you describe. The only way to analyze dependencies is by #include directives, which aren't even reliable. Ones that aren't needed don't necessarily get removed. And others that should be added aren't, because the header in question gets accidentally included, transitively. Sometimes A.cpp #includes B.h, and B.cpp #includes A.h for reasons of collaboration. Such circular dependencies are sometimes unavoidable. Layering is the main way to impose higher level structure. The software is organized into static or dynamic libraries that preclude circular dependencies. That is, if library B has a file that #includes a file in library A, then no file in A can #include anything in B. This allows libraries to be tested independently and also allows an application to be developed without having to use a monolithic code base that contains various things that the application doesn't need.

          Robust Services Core | Software Techniques for Lemmings | Articles
          The fox knows many things, but the hedgehog knows one big thing.

          <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
          <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

          1 Reply Last reply
          0
          • L Lost User

            CalinNegru wrote:

            software projects don`t have superstructures.

            If they a re poorly managed that is generally true. But a well organised project will always have a lot of structure.

            C Offline
            C Offline
            Calin Negru
            wrote on last edited by
            #5

            In c things probably aren`t that much elaborate but if we talk c++ is a factory a superstructure? To my mind a factory is the environment designed to handle `well` class instances.

            J L 2 Replies Last reply
            0
            • C Calin Negru

              In c things probably aren`t that much elaborate but if we talk c++ is a factory a superstructure? To my mind a factory is the environment designed to handle `well` class instances.

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              A factory is a way of organizing certain things based on a certain need. It applies to most (probably all) Object Oriented languages. I can also state that although a bit odd you can create something similar in C.

              C 1 Reply Last reply
              0
              • C Calin Negru

                Looking at a large project and trying to figure out how it all works I realized that unlike real life software projects don`t have superstructures. It`s all rather scattered/fragmented. Code files have links to other pieces of code via the header files present at the begging of each cpp file and that`s about it.

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #7

                CalinNegru wrote:

                Looking at a large project

                Depends on what "large" actually means... In the real world companies end up with software that was created by many people over time. As with everything else that humans are involved in quality tends towards the average. That includes design which impacts what you refer to as 'structure'. Programmers also like to think that they know for certain that the best way to do something is the way they know. Which is completely subjective. So they create new 'better' solutions willy-nilly and hack them into existing code bases because of that. Then they leave the company and someone else starts doing it. Overtime this leads to significant organizational problems. Even in the best systems there are real world business requirements that only come up long after the original design and for which the original design did not account. And the company is not willing to pay to refactor the entire code base when this happens. Even worse if it wasn't well designed. Or with 'better' ways on top of it. And developers seldom consider the long term impact on maintenance when they make radical decisions to go in a different direction on a code base. It is known (multiple studies) that maintenance costs are always 2 to 10 times higher than the original cost to develop the product. And 100 times higher is probably reasonable for some. Might note that although I point out developers in the above I have never seen a company that was actually willing to recognize the maintenance costs much less put an emphasis on mitigating for that.

                1 Reply Last reply
                0
                • J jschell

                  A factory is a way of organizing certain things based on a certain need. It applies to most (probably all) Object Oriented languages. I can also state that although a bit odd you can create something similar in C.

                  C Offline
                  C Offline
                  Calin Negru
                  wrote on last edited by
                  #8

                  Quote:

                  A factory is a way of organizing certain things based on a certain need.

                  You make factory sound like a vague notion, to my knowledge it`s a well defined pattern to create objects.

                  J 1 Reply Last reply
                  0
                  • C Calin Negru

                    Quote:

                    A factory is a way of organizing certain things based on a certain need.

                    You make factory sound like a vague notion, to my knowledge it`s a well defined pattern to create objects.

                    J Offline
                    J Offline
                    jeron1
                    wrote on last edited by
                    #9

                    CalinNegru wrote:

                    to my knowledge it`s a well defined pattern to create objects.

                    I didn't see where they implied otherwise.

                    "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

                    C 1 Reply Last reply
                    0
                    • J jeron1

                      CalinNegru wrote:

                      to my knowledge it`s a well defined pattern to create objects.

                      I didn't see where they implied otherwise.

                      "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

                      C Offline
                      C Offline
                      Calin Negru
                      wrote on last edited by
                      #10

                      why the rhetoric? I wasn`t arguing I was only seeking explanations.

                      1 Reply Last reply
                      0
                      • C Calin Negru

                        In c things probably aren`t that much elaborate but if we talk c++ is a factory a superstructure? To my mind a factory is the environment designed to handle `well` class instances.

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

                        It depends what you mean by a "factory". The Factory Pattern is a well defined method of creating certain objects, based on a class structure. But you can still write well structure projects without using it.

                        C 1 Reply Last reply
                        0
                        • L Lost User

                          It depends what you mean by a "factory". The Factory Pattern is a well defined method of creating certain objects, based on a class structure. But you can still write well structure projects without using it.

                          C Offline
                          C Offline
                          Calin Negru
                          wrote on last edited by
                          #12

                          What is the default approach for creating objects using a factory? When one is creating several objects of the same class using a factory is the factory class retaining the objects as an array/std container and returning through a function a pointer to the object that has been created (which can be stored into an array/container outside the factory class)? this is code for creating a single object

                          #include using namespace std;

                          class Vehicle {
                          public:
                          virtual void printVehicle() = 0;
                          static Vehicle* Create(VehicleType type);
                          };
                          class TwoWheeler : public Vehicle {
                          public:
                          void printVehicle() {
                          cout << "I am two wheeler" << endl;
                          }
                          };

                          Vehicle* Vehicle::Create() {
                          return new TwoWheeler();
                          }

                          // Client class
                          class Client {
                          public:

                          Client() 
                          { 
                              
                          } 
                          
                          ~Client() { 
                              if (pVehicle) { 
                                  delete\[\] pVehicle; 
                                  pVehicle = NULL; 
                              } 
                          } 
                          void BuildVehicle()
                          {
                           pVehicle = Vehicle::Create(); 
                          }
                          Vehicle\* getVehicle()  { 
                              return pVehicle; 
                          } 
                          

                          private:
                          Vehicle *pVehicle;
                          };

                          int main() {
                          Client *pClient = new Client();
                          pClient->BuildVechicle();
                          Vehicle * pVehicle = pClient->getVehicle();
                          pVehicle->printVehicle();
                          return 0;
                          }

                          how should the modified version of main() look like if you want more than one vehicle to be created

                          L 1 Reply Last reply
                          0
                          • C Calin Negru

                            What is the default approach for creating objects using a factory? When one is creating several objects of the same class using a factory is the factory class retaining the objects as an array/std container and returning through a function a pointer to the object that has been created (which can be stored into an array/container outside the factory class)? this is code for creating a single object

                            #include using namespace std;

                            class Vehicle {
                            public:
                            virtual void printVehicle() = 0;
                            static Vehicle* Create(VehicleType type);
                            };
                            class TwoWheeler : public Vehicle {
                            public:
                            void printVehicle() {
                            cout << "I am two wheeler" << endl;
                            }
                            };

                            Vehicle* Vehicle::Create() {
                            return new TwoWheeler();
                            }

                            // Client class
                            class Client {
                            public:

                            Client() 
                            { 
                                
                            } 
                            
                            ~Client() { 
                                if (pVehicle) { 
                                    delete\[\] pVehicle; 
                                    pVehicle = NULL; 
                                } 
                            } 
                            void BuildVehicle()
                            {
                             pVehicle = Vehicle::Create(); 
                            }
                            Vehicle\* getVehicle()  { 
                                return pVehicle; 
                            } 
                            

                            private:
                            Vehicle *pVehicle;
                            };

                            int main() {
                            Client *pClient = new Client();
                            pClient->BuildVechicle();
                            Vehicle * pVehicle = pClient->getVehicle();
                            pVehicle->printVehicle();
                            return 0;
                            }

                            how should the modified version of main() look like if you want more than one vehicle to be created

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

                            That is not really about a Factory, just about creating objects. If you want a good introduction to the Factory Pattern I recommend the articles by @SneshPrajapati, starting with: Factory Patterns - Simple Factory Pattern[^].

                            C S 2 Replies Last reply
                            0
                            • L Lost User

                              That is not really about a Factory, just about creating objects. If you want a good introduction to the Factory Pattern I recommend the articles by @SneshPrajapati, starting with: Factory Patterns - Simple Factory Pattern[^].

                              C Offline
                              C Offline
                              Calin Negru
                              wrote on last edited by
                              #14

                              I`ve had a look at Snesh`s profile, thank you.

                              Quote:

                              That is not really about a Factory, just about creating objects

                              I know. But things are meant to be learned in a certain order. Factory seems to be the next thing to learn after the "c++ class" lesson. Factory stands for more than just one thing, but those things designated with the word 'factory' although different they still somehow resemble. Basically the factory pattern upgrades the understanding of constructor and destructor concepts. It`s like traditional German house windows, everybody knows Germans are the best car makers. That means they gave a good grip on the things that go into making a car. Germans had the best tanks in WWII so that explains why Germans have a good grip on the concept of car body/frame. The problem is tanks didn`t had windows (and still don`t till this day) so someone arranged things such that Germans have a good grip on the concept of physical windows too, German houses have a two layer windows system (which is basically two windows in one): the usual window made of glass and metal/wood frame and then the wooden only layer/covering meant to protect the windows from physical damage.

                              L 1 Reply Last reply
                              0
                              • C Calin Negru

                                I`ve had a look at Snesh`s profile, thank you.

                                Quote:

                                That is not really about a Factory, just about creating objects

                                I know. But things are meant to be learned in a certain order. Factory seems to be the next thing to learn after the "c++ class" lesson. Factory stands for more than just one thing, but those things designated with the word 'factory' although different they still somehow resemble. Basically the factory pattern upgrades the understanding of constructor and destructor concepts. It`s like traditional German house windows, everybody knows Germans are the best car makers. That means they gave a good grip on the things that go into making a car. Germans had the best tanks in WWII so that explains why Germans have a good grip on the concept of car body/frame. The problem is tanks didn`t had windows (and still don`t till this day) so someone arranged things such that Germans have a good grip on the concept of physical windows too, German houses have a two layer windows system (which is basically two windows in one): the usual window made of glass and metal/wood frame and then the wooden only layer/covering meant to protect the windows from physical damage.

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

                                CalinNegru wrote:

                                I`ve had a look at Snesh`s profile, thank you.

                                I meant you to read her articles, if you really want to understand Factories in programming.

                                1 Reply Last reply
                                0
                                • L Lost User

                                  That is not really about a Factory, just about creating objects. If you want a good introduction to the Factory Pattern I recommend the articles by @SneshPrajapati, starting with: Factory Patterns - Simple Factory Pattern[^].

                                  S Offline
                                  S Offline
                                  Snesh Prajapati
                                  wrote on last edited by
                                  #16

                                  :thumbsup: Thanks.

                                  1 Reply Last reply
                                  0
                                  • B Bohdan Stupak

                                    I've seen code files with couple of thousand lines and I must say that there is luckily no megastructures as such file are quite complex to reason about, support and put them under test

                                    M Offline
                                    M Offline
                                    Member_15586253
                                    wrote on last edited by
                                    #17

                                    Hello friends👋, Take a look at this GitHub repository📚. You can find various problems💡 and concepts of Data Structures and Algorithms in Python3 🐍stored in a structured 🎯manner. Please give star⭐ and fork also. https://github.com/SamirPaul1/DSAlgo

                                    1 Reply Last reply
                                    0
                                    • B Bohdan Stupak

                                      I've seen code files with couple of thousand lines and I must say that there is luckily no megastructures as such file are quite complex to reason about, support and put them under test

                                      V Offline
                                      V Offline
                                      Vsvirtual shop
                                      wrote on last edited by
                                      #18

                                      faiza saqlain replica: https://vsvirtualshop.com/product/master-replica-of-maya-ali-wear-by-faiza-saqlain/

                                      1 Reply Last reply
                                      0
                                      • L Lost User

                                        CalinNegru wrote:

                                        software projects don`t have superstructures.

                                        If they a re poorly managed that is generally true. But a well organised project will always have a lot of structure.

                                        M Offline
                                        M Offline
                                        Member 15078716
                                        wrote on last edited by
                                        #19

                                        I agree.

                                        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