Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > BOOK: Professional ASP.NET Design Patterns
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET Design Patterns
This is the forum to discuss the Wrox book Professional ASP.NET Design Patterns by Scott Millett; ISBN: 978-0-470-29278-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET Design Patterns section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 11th, 2012, 09:44 AM
Registered User
Points: 46, Level: 1
Points: 46, Level: 1 Points: 46, Level: 1 Points: 46, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2010
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default pg 81 why is there 2 constructors with paramaters flipped?

public ApplicationBankAccountService(
IBankAccountRepository bankRepository,
BankAccountService bankAccountService)
{
_bankRepository = bankRepository;
_bankAccountService = bankAccountService;
}
public ApplicationBankAccountService(
BankAccountService bankAccountService,
IBankAccountRepository bankRepository)
{
_bankAccountService = bankAccountService;
_bankRepository = bankRepository;
}
Reply With Quote
  #2 (permalink)  
Old February 12th, 2012, 03:31 PM
Friend of Wrox
Points: 742, Level: 10
Points: 742, Level: 10 Points: 742, Level: 10 Points: 742, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2009
Location: Tehran, Iran
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default nothing

maybe because of flexibility and easy to use
__________________
happy every time, happy every where

Reza Baiat
Reply With Quote
  #3 (permalink)  
Old February 24th, 2012, 09:53 AM
Registered User
Points: 46, Level: 1
Points: 46, Level: 1 Points: 46, Level: 1 Points: 46, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2010
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default

the parameters are both of the same types making it no more flexible and more confusing.
Reply With Quote
  #4 (permalink)  
Old February 25th, 2012, 01:40 AM
Friend of Wrox
Points: 742, Level: 10
Points: 742, Level: 10 Points: 742, Level: 10 Points: 742, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2009
Location: Tehran, Iran
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Smile

Hi there

imagine you are writing a function named Add that adds two float and int values. how do you write it?

float Add(float a, int b){

}

or maybe

float Add(int a, float b){

}

or maybe overloaded and coupled choice:

Code:
float Add(float a, int b){
 return a+b;
}

float Add(int a, float b){
 return a+b;
}
I think the complete choice is the best. so user is not limited to pass numbers in a special order.

float x = Add(2, 2.564);
float y = Add(345.9374, 17);
__________________
happy every time, happy every where

Reza Baiat
Reply With Quote
  #5 (permalink)  
Old February 25th, 2012, 05:49 AM
elbandit's Avatar
Wrox Author
Points: 599, Level: 8
Points: 599, Level: 8 Points: 599, Level: 8 Points: 599, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2007
Location: Southsea, Portsmouth, Hampshire, United Kingdom.
Posts: 107
Thanks: 10
Thanked 17 Times in 15 Posts
Default

Hi guys, this is a typo I'm afraid - sorry.

Although you do touch on a topic that I will be covering in my new book. That of primitive obsession. Take this code...

Code:
decimal apply_vat(decimal price, decimal vat_rare)
{
     //logic ....
}
It would be easy to get the parameters confused when calling...

Code:
decimal price_after_vat = apply_vat(1.23, 199.99); // Whoops!
Better to use value types and make things explicit...

Code:
Money apply_vat(Money price, VatRate vat)
{
  .....
}
Or better still...

Code:
Public Class Money
{
     Money apply(VatRate vat)
     {
          // return new Money with vat applied
      }
}
This way you avoid confusion, you make the concepts of money and vat more explicit and you enable them to encapsulate behaviour.

Thoughts?

Cheers
Scott
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error following directions on page 81. rnes BOOK: Windows Phone 7 Application Development: 24 Hour Trainer 1 January 30th, 2012 06:14 PM
Error Message on Page 81 vbboyd BOOK: Professional ASP.NET MVC 3 0 October 25th, 2011 01:54 AM
Automatically add querystring paramaters to URL trancehead ASP.NET 2.0 Professional 0 July 24th, 2006 03:03 AM
multivalue paramaters are not supported diegoo BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 February 20th, 2005 02:30 AM



All times are GMT -4. The time now is 07:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.