Click here to Skip to main content
15,896,397 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
AnswerRe: Does a developer need local administrator rights? Pin
Sir Dot Net19-Nov-09 7:50
Sir Dot Net19-Nov-09 7:50 
AnswerRe: Does a developer need local administrator rights? [modified] Pin
Flint-Bear8-Dec-09 5:14
Flint-Bear8-Dec-09 5:14 
QuestionEmpty IEnumerable or null Pin
Gideon Engelberth10-Nov-09 9:19
Gideon Engelberth10-Nov-09 9:19 
AnswerRe: Empty IEnumerable or null Pin
Luc Pattyn10-Nov-09 13:36
sitebuilderLuc Pattyn10-Nov-09 13:36 
GeneralRe: Empty IEnumerable or null Pin
Gideon Engelberth16-Nov-09 5:21
Gideon Engelberth16-Nov-09 5:21 
AnswerRe: Empty IEnumerable or null Pin
David Skelly10-Nov-09 22:47
David Skelly10-Nov-09 22:47 
GeneralRe: Empty IEnumerable or null Pin
Gideon Engelberth16-Nov-09 5:22
Gideon Engelberth16-Nov-09 5:22 
QuestionRun to Completion Pin
Leslie Sanford4-Nov-09 13:51
Leslie Sanford4-Nov-09 13:51 
The concept of Run to Completion means, at least as it pertains to classes, that a method must run to its end before another method can be called on the same object. Adhering to this rule makes it easier to reason about a class's state.

I've often seen examples of this rule being broken or just ignored. How often does a class call one of its methods in the middle of another method? I've done this many times, and I've seen code authored by others do the same thing. As long as the method being called is read-only, I don't think RTC is being violated. But when it's a write method, I've wondered if this isn't an indication of a code smell.

I was looking at Sams Teach Yourself Object Oriented Programming in 21 Days. In the book is a step-by-step example of designing an object oriented blackjack game. Here's an excerpt of part of the code from that example:

// In the Player class
public void play(Dealer dealer)
{
    while(!isBusted() && hit())
    {
        dealer.hit(this);
    }
}

public void addCard(Card card)
{
    hand.addCard(card);
    notifyListeners();
}

public boolean isBusted()
{
    return hand.isBusted();
}

// In the Dealer class
public void hit(Player player)
{
    player.addCard(cards.dealUp());
}


There's a circular nature to this design which doesn't sit well with me. But setting that aside, what I want to get at is what the player class is up to in the play method. This method passes its instance to the Dealer which in turn calls the Players addCard method. This method adds a card to the player's hand. Back in the play method, the loop checks to see if the hand is busted. It's depending on the Dealer to make a change in its state elsewhere.

I don't know; maybe there's nothing wrong with this approach. It just seems fragmented to me. The play method is depending on state changes made via another method that it expects to be called while it (the play method) is still executing.

I'm not sure how I would approach this, but I was curious as to whether anyone else sees anything wrong with this.
QuestionWindows Service Pin
Archimedes2427-Oct-09 22:13
professionalArchimedes2427-Oct-09 22:13 
AnswerRe: Windows Service Pin
Covean27-Oct-09 23:07
Covean27-Oct-09 23:07 
AnswerRe: Windows Service Pin
Sir Dot Net19-Nov-09 8:01
Sir Dot Net19-Nov-09 8:01 
AnswerRe: Windows Service Pin
puri keemti7-Dec-09 0:39
puri keemti7-Dec-09 0:39 
QuestionUsing MSMQ along with BizTalk Pin
Member 188237827-Oct-09 9:18
Member 188237827-Oct-09 9:18 
AnswerRe: Using MSMQ along with BizTalk Pin
Member 188237827-Oct-09 23:55
Member 188237827-Oct-09 23:55 
QuestionFinancial Software Designs Pin
motapa21-Oct-09 8:36
motapa21-Oct-09 8:36 
AnswerRe: Financial Software Designs Pin
Eddy Vluggen30-Oct-09 4:18
professionalEddy Vluggen30-Oct-09 4:18 
AnswerRe: Financial Software Designs Pin
puri keemti7-Dec-09 0:41
puri keemti7-Dec-09 0:41 
QuestionOpinion survey about ORM / DAL tools Pin
midix20-Oct-09 23:44
midix20-Oct-09 23:44 
AnswerRe: Opinion survey about ORM / DAL tools Pin
midix9-Nov-09 8:40
midix9-Nov-09 8:40 
AnswerRe: Opinion survey about ORM / DAL tools Pin
Sir Dot Net19-Nov-09 8:04
Sir Dot Net19-Nov-09 8:04 
QuestionHelp files fomat Pin
marca2928-Oct-09 1:42
marca2928-Oct-09 1:42 
QuestionQuestion on dependency of Business Layer with Data Access Layer Pin
meeram39527-Sep-09 21:54
meeram39527-Sep-09 21:54 
AnswerRe: Question on dependency of Business Layer with Data Access Layer Pin
Ian Shlasko28-Sep-09 3:21
Ian Shlasko28-Sep-09 3:21 
AnswerRe: Question on dependency of Business Layer with Data Access Layer Pin
Rozis29-Sep-09 4:46
Rozis29-Sep-09 4:46 
GeneralRe: Question on dependency of Business Layer with Data Access Layer Pin
machadogj13-Oct-09 7:39
machadogj13-Oct-09 7:39 

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.