Click here to Skip to main content
12,818,664 members (29,906 online)

Design and Architecture

 
QuestionSCRUM Pin
Civic0610-Jan-11 10:44
memberCivic0610-Jan-11 10:44 
AnswerRe: SCRUM Pin
Rags151210-Jan-11 18:47
memberRags151210-Jan-11 18:47 
GeneralRe: SCRUM Pin
Civic0611-Jan-11 3:10
memberCivic0611-Jan-11 3:10 
GeneralRe: SCRUM Pin
Rags151211-Jan-11 19:54
memberRags151211-Jan-11 19:54 
GeneralRe: SCRUM Pin
RaviSant17-Jan-11 22:57
memberRaviSant17-Jan-11 22:57 
QuestionObject heuristic Pin
Leslie Sanford5-Jan-11 12:35
memberLeslie Sanford5-Jan-11 12:35 
AnswerRe: Object heuristic Pin
Luc Pattyn5-Jan-11 14:06
mvpLuc Pattyn5-Jan-11 14:06 
GeneralRe: Object heuristic Pin
Leslie Sanford5-Jan-11 14:51
memberLeslie Sanford5-Jan-11 14: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 Pin
Luc Pattyn5-Jan-11 15:06
mvpLuc Pattyn5-Jan-11 15:06 
AnswerRe: Object heuristic Pin
paul_717-Jan-11 2:24
memberpaul_717-Jan-11 2:24 
QuestionDatabase Code Pin
Leslie Sanford5-Jan-11 6:46
memberLeslie Sanford5-Jan-11 6:46 
AnswerRe: Database Code Pin
dasblinkenlight12-Jan-11 12:42
memberdasblinkenlight12-Jan-11 12:42 
QuestionMatching between product and customer personal information Pin
Yanshof3-Jan-11 21:07
memberYanshof3-Jan-11 21:07 
AnswerRe: Matching between product and customer personal information Pin
dasblinkenlight13-Jan-11 7:24
memberdasblinkenlight13-Jan-11 7:24 
QuestionNeed guidance on designing and preparing MCPD Pin
Rags15123-Jan-11 8:11
memberRags15123-Jan-11 8:11 
AnswerRe: Need guidance on designing and preparing MCPD Pin
Richard MacCutchan4-Jan-11 6:36
mvpRichard MacCutchan4-Jan-11 6:36 
GeneralRe: Need guidance on designing and preparing MCPD Pin
Rags15124-Jan-11 18:21
memberRags15124-Jan-11 18:21 
GeneralRe: Need guidance on designing and preparing MCPD Pin
Richard MacCutchan4-Jan-11 22:39
mvpRichard MacCutchan4-Jan-11 22:39 
QuestionPossible inefficiency in post-increment FOR loop? Pin
Xpnctoc30-Dec-10 16:12
memberXpnctoc30-Dec-10 16:12 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
Richard MacCutchan31-Dec-10 0:05
mvpRichard MacCutchan31-Dec-10 0:05 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
Luc Pattyn31-Dec-10 0:37
mvpLuc Pattyn31-Dec-10 0:37 
GeneralRe: Possible inefficiency in post-increment FOR loop? Pin
fat_boy31-Dec-10 3:12
memberfat_boy31-Dec-10 3:12 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
fat_boy31-Dec-10 3:13
memberfat_boy31-Dec-10 3:13 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
Peter_in_27804-Jan-11 19:21
memberPeter_in_27804-Jan-11 19:21 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
dasblinkenlight13-Jan-11 3:18
memberdasblinkenlight13-Jan-11 3:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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
Web02 | 2.8.170308.1 | Last Updated 16 Mar 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid