Click here to Skip to main content

Design and Architecture

 
QuestionNeed Design Ideas PinmemberKevin Marois12-Jan-11 10:41 
AnswerRe: Need Design Ideas PinmvpPete O'Hanlon12-Jan-11 21:24 
AnswerRe: Need Design Ideas PinmemberGParkings2-Sep-11 2:40 
QuestionApplication design code samples PinmemberChesnokov Yuriy12-Jan-11 4:29 
AnswerRe: Application design code samples PinmemberEddy Vluggen12-Jan-11 4:52 
AnswerRe: Application design code samples PinmemberKevin Marois12-Jan-11 5:54 
QuestionSCRUM PinmemberCivic0610-Jan-11 9:44 
AnswerRe: SCRUM PinmemberRags151210-Jan-11 17:47 
GeneralRe: SCRUM PinmemberCivic0611-Jan-11 2:10 
GeneralRe: SCRUM PinmemberRags151211-Jan-11 18:54 
GeneralRe: SCRUM PinmemberRaviSant17-Jan-11 21:57 
QuestionObject heuristic PinmemberLeslie Sanford5-Jan-11 11:35 
AnswerRe: Object heuristic PinmvpLuc Pattyn5-Jan-11 13:06 
GeneralRe: Object heuristic PinmemberLeslie Sanford5-Jan-11 13:51 
Luc Pattyn wrote:
From your snippet it isn't really clear why you need two classes in the first place. I also expect real names for the classes would make things more obvious.

 
It was a quick and dirty example. I'll try to do better. Smile | :)
 
I've been doing iPhone programming, and using the Model/View/Controller pattern (or at least one variation of it) is encouraged by the architecture. Say we have a model.
 
class Model
{
public:
    // Stuff...
};
 
The controller uses the model, but should it also be responsible for creating it? Assume for the sake of argument that an instance of the model isn't used any where else besides the controller class. I guess it then becomes academic, but I seem to remember reading some where that objects shouldn't use the objects they create. I can't remember why or where I read that.
 
I was wondering if this:
 
class Controller
{
public:
    Controller(Model *model)
    {
        this->model = model
    }
};
 
Is better than this:
 
class Controller
{
public:
    Controller()
    {
        this->model = new Model();
    }
};
 
Maybe the reasoning as to why the first approach is better is that if we use polymorphism, we can switch out which model is used by the Controller; we can't do that in the second example without changing the Controller class.
 
Also, maybe as a general rule factory code should be seperate from the rest of the code?
GeneralRe: Object heuristic PinmvpLuc Pattyn5-Jan-11 14:06 
AnswerRe: Object heuristic Pinmemberpaul_717-Jan-11 1:24 
QuestionDatabase Code PinmemberLeslie Sanford5-Jan-11 5:46 
AnswerRe: Database Code Pinmemberdasblinkenlight12-Jan-11 11:42 
QuestionMatching between product and customer personal information PinmemberYanshof3-Jan-11 20:07 
AnswerRe: Matching between product and customer personal information Pinmemberdasblinkenlight13-Jan-11 6:24 
QuestionNeed guidance on designing and preparing MCPD PinmemberRags15123-Jan-11 7:11 
AnswerRe: Need guidance on designing and preparing MCPD PinmvpRichard MacCutchan4-Jan-11 5:36 
GeneralRe: Need guidance on designing and preparing MCPD PinmemberRags15124-Jan-11 17:21 
GeneralRe: Need guidance on designing and preparing MCPD PinmvpRichard MacCutchan4-Jan-11 21:39 
QuestionPossible inefficiency in post-increment FOR loop? PinmemberXpnctoc30-Dec-10 15:12 
AnswerRe: Possible inefficiency in post-increment FOR loop? PinmvpRichard MacCutchan30-Dec-10 23:05 
AnswerRe: Possible inefficiency in post-increment FOR loop? PinmvpLuc Pattyn30-Dec-10 23:37 
GeneralRe: Possible inefficiency in post-increment FOR loop? Pinmemberfat_boy31-Dec-10 2:12 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pinmemberfat_boy31-Dec-10 2:13 
AnswerRe: Possible inefficiency in post-increment FOR loop? PinmemberPeter_in_27804-Jan-11 18:21 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pinmemberdasblinkenlight13-Jan-11 2:18 
QuestionDiagramming? Pinmemberdawmail33328-Dec-10 22:48 
AnswerRe: Diagramming? Pinmemberfat_boy31-Dec-10 2:18 
QuestionDeveloping to try to make a difference? PinmemberTodd Baxter28-Dec-10 3:16 
AnswerRe: Developing to try to make a difference? PinmvpPete O'Hanlon28-Dec-10 3:27 
GeneralRe: Developing to try to make a difference? PinmemberTodd Baxter28-Dec-10 5:06 
GeneralRe: Developing to try to make a difference? Pinmemberjk chan28-Dec-10 21:49 
GeneralRe: Developing to try to make a difference? PinmemberTodd Baxter29-Dec-10 3:15 
GeneralRe: Developing to try to make a difference? Pinmemberjk chan29-Dec-10 4:01 
AnswerRe: Developing to try to make a difference? [modified] PingroupRobert Croll4-Jan-11 3:24 
GeneralRe: Developing to try to make a difference? PinmemberTodd Baxter4-Jan-11 5:04 
GeneralRe: Developing to try to make a difference? PingroupRobert Croll4-Jan-11 6:21 
GeneralRe: Developing to try to make a difference? PinmemberTodd Baxter4-Jan-11 6:44 
GeneralRe: Developing to try to make a difference? PingroupRobert Croll4-Jan-11 7:29 
GeneralRe: Developing to try to make a difference? PinmemberMycroft Holmes13-Jan-11 12:16 
GeneralRe: Developing to try to make a difference? PinmemberTodd Baxter17-Jan-11 2:37 
GeneralRe: Developing to try to make a difference? PinmemberTodd Baxter17-Jan-11 4:08 
QuestionHelp: Which design method should I use for this particular case? Pinmemberxyzsnl27-Dec-10 2:44 
AnswerRe: Help: Which design method should I use for this particular case? PinmvpEddy Vluggen28-Dec-10 7:42 
AnswerRe: Help: Which design method should I use for this particular case? PingroupRobert Croll4-Jan-11 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 21 Oct 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid