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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. A strange question I think

A strange question I think

Scheduled Pinned Locked Moved C#
questionlearningdatabasedesignsysadmin
4 Posts 2 Posters 1 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
    Christer Claesson
    wrote on last edited by
    #1

    I have this project in school, doing a project and while the code is the small part(main thing is learning use RUP and so on) it is still kinda tricky. Not codewise but design wise. Right now we have one Project class, one Resource class, one Employee class, one "main" class and a "storage manager".(The program will be quite bigger eventually but this is the gist of it). The program can handle several projects and several employees. And we added a resource class "between" employee and project, ie a resource can only have one project and one employee and it keeps the information needed. Like how many hours the employee should work on the project and so on. At first we had no relation between these three classes, instead we had a database way of thinking and used a "foreign key" a employee id and project id in resource. But instead it was recommended to us that a good object oriented design should have associations instead. So I've have been thinking of adding knowledge of project and employee to the resource class and both the employee and project should know about the resource. Will this be good or just too "cluttered". Another problem we faced was that if that many objects are bound to each other we will have trouble sending them back and forth to our server.(Or will we?) Any tips of design patterns or just general tips about how we can do? (Not asking you too do school work for me here ;) , we are actually recommended seeking information on the Internet)

    C 1 Reply Last reply
    0
    • C Christer Claesson

      I have this project in school, doing a project and while the code is the small part(main thing is learning use RUP and so on) it is still kinda tricky. Not codewise but design wise. Right now we have one Project class, one Resource class, one Employee class, one "main" class and a "storage manager".(The program will be quite bigger eventually but this is the gist of it). The program can handle several projects and several employees. And we added a resource class "between" employee and project, ie a resource can only have one project and one employee and it keeps the information needed. Like how many hours the employee should work on the project and so on. At first we had no relation between these three classes, instead we had a database way of thinking and used a "foreign key" a employee id and project id in resource. But instead it was recommended to us that a good object oriented design should have associations instead. So I've have been thinking of adding knowledge of project and employee to the resource class and both the employee and project should know about the resource. Will this be good or just too "cluttered". Another problem we faced was that if that many objects are bound to each other we will have trouble sending them back and forth to our server.(Or will we?) Any tips of design patterns or just general tips about how we can do? (Not asking you too do school work for me here ;) , we are actually recommended seeking information on the Internet)

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Cenatar wrote: So I've have been thinking of adding knowledge of project and employee to the resource class and both the employee and project should know about the resource. Will this be good or just too "cluttered". It depends on which way you need to travel through the objects. I would imaging your suggestion above is correct. Asking yourself some questions like: Does an employee object need to know about the projects it is connected with? Does a project object need to know about the employees working on it? If it is "yes" in both cases then: Project keeps a collection of references to its resources Resource keeps a reference to its project and the employee Employee keeps a collection of references to its resources


      "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September

      C 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Cenatar wrote: So I've have been thinking of adding knowledge of project and employee to the resource class and both the employee and project should know about the resource. Will this be good or just too "cluttered". It depends on which way you need to travel through the objects. I would imaging your suggestion above is correct. Asking yourself some questions like: Does an employee object need to know about the projects it is connected with? Does a project object need to know about the employees working on it? If it is "yes" in both cases then: Project keeps a collection of references to its resources Resource keeps a reference to its project and the employee Employee keeps a collection of references to its resources


        "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September

        C Offline
        C Offline
        Christer Claesson
        wrote on last edited by
        #3

        Colin Angus Mackay wrote: Project keeps a collection of references to its resources Resource keeps a reference to its project and the employee Employee keeps a collection of references to its resources That is actually exactly how we imagined it thank you, but later wont this be a big mess when we try and transfer it to the server? ie what happens when I get a project from the server(or database) and I want to see what resources that is connected to it? This might be a stupid question, as I've not looked into this at all. Will do that though, but thank you for your help.

        C 1 Reply Last reply
        0
        • C Christer Claesson

          Colin Angus Mackay wrote: Project keeps a collection of references to its resources Resource keeps a reference to its project and the employee Employee keeps a collection of references to its resources That is actually exactly how we imagined it thank you, but later wont this be a big mess when we try and transfer it to the server? ie what happens when I get a project from the server(or database) and I want to see what resources that is connected to it? This might be a stupid question, as I've not looked into this at all. Will do that though, but thank you for your help.

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Cenatar wrote: what happens when I get a project from the server(or database) and I want to see what resources that is connected to it? What do you mean? That depends on how you want to implement it, what technologies are abailable and so on. If you are concerned about large ammounts of data transferring in one go you could implement a lazy fetch algorithm. In other words, you get the project as your starting point. Then if you need to iterate through the list of resources, you'll access that collection through a property and the internal code of the property checks whether the information is available yet and if not builds the collection by fetching the relevant data from the database. The resource object will expose properties that get you to the project and employee with a lazy fetch algorithm, since the project already exists that reference will be reused, but since the employee doesn't exist in your application any attempt to get the employee property will, for the first time, perform a database lookup. Be warned that over zealous use of lazy fetch (aka lazy lookup) algorithms can hurt performance, however some uses, like in matrix classes (and this is more of a lazy calculation, than lookup) can work very well if you don't need to know everything about the matrix. As a general rule, try and fetch as much as possible in one request (without fetching so much the user is left waiting) because it reduces network traffic (one request and lots of data in the reply, rather than lots of requests and lots of replies - which probably won't fill network packets efficiently). Does this help?


          "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September

          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