Click here to Skip to main content
11,640,445 members (62,594 online)

Design and Architecture

 
Questionrich text editor Pin
Danielos_s2330-Jan-13 10:03
memberDanielos_s2330-Jan-13 10:03 
AnswerRe: rich text editor Pin
José Amílcar Ferreira Casimiro11-Feb-13 5:37
memberJosé Amílcar Ferreira Casimiro11-Feb-13 5:37 
QuestionMVVM, EF and TDD tutorials Pin
cansino17-Jan-13 6:06
membercansino17-Jan-13 6:06 
QuestionJava and C# operating on the same data in an ASP-based monitoring web application. Pin
vValkir17-Jan-13 0:18
membervValkir17-Jan-13 0:18 
AnswerRe: Java and C# operating on the same data in an ASP-based monitoring web application. Pin
Jonathan C Dickinson17-Jan-13 3:05
memberJonathan C Dickinson17-Jan-13 3:05 
Questionindesign cs6 trial - no toolbar Pin
Member 93448236-Jan-13 12:10
memberMember 93448236-Jan-13 12:10 
AnswerRe: indesign cs6 trial - no toolbar Pin
Pete O'Hanlon17-Jan-13 0:49
protectorPete O'Hanlon17-Jan-13 0:49 
QuestionHow do you design this? : with a better example Pin
VuNic30-Dec-12 17:57
memberVuNic30-Dec-12 17:57 
There is a huge hybrid battle ship that sail, load cargo, carry ammunition, commandos, & sometimes go down the water like a submarine, and some time camouflager itself based on the surroundings. It does a lot of things, & equally has a lot of properties like, color, size, Housing capacity, firing capabilities. etc.


Now, on the ship, there's only one place where I can mount ammunition.

I have a set of ammunition. Anti-aircraft guns, fire shells, Launch missiles, etc etc. but all these are "mutually exclusive".

If I would like to mount the ship with Anti-aircraft guns, all other ammo go unusable. I can dynamically swap between available ammo.

class BattleShip
{
  propert A,B ,.....Z;
 
  void MountAndFire(Ammo ammo_in)
  {
 
//if it's a gun,
	int ammo_in.Fire(numberofrounds:30);  //returns remaining ammo
   
// if it's a missle launcher:
        float  ammo_in.Fire(direction:120, distance:200); // return ammount of heat it generated on the ship

//cluster bomb
        int ammo_in.Fire(Numberofcluster:600, direction:120, Distance:200);// Returns something else

  }
 
};


How do you have a generic design to address this? I thought of having a Ammo Interface, and have a Fire() call,
But the parameter for the fire call differ for all the ammo. So I cant' say:

interface IAmmo
{
  virtual int Fire();
 
}
 
Missile: IAmmo
{
 int  Fire()
{
} 
} 


The simple ordinary way is to check:
void MountAndFire(object ammo_in)
  {
 

//if it's a gun,

        if(ammo_in.GetType==typeof(Antiaircraftgun)
	    {
            AntiAirCraftGun aag = (AntiAirCraftGun) ammo_in;
 
            aag.Fire(30);
        }
 
//Missle
        if(ammo_in.GetType==typeof(Missile)
	    {
            Missle missile = (Missile) ammo_in;
 
            missile.Fire(120,200);   
        }
	    
	
  }

You have a better idea for this?

Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

AnswerRe: How do you design this? : with a better example Pin
Christian Graus30-Dec-12 18:25
mvpChristian Graus30-Dec-12 18:25 
GeneralRe: How do you design this? : with a better example Pin
VuNic30-Dec-12 18:42
memberVuNic30-Dec-12 18:42 
GeneralRe: How do you design this? : with a better example Pin
Christian Graus30-Dec-12 18:46
mvpChristian Graus30-Dec-12 18:46 
AnswerRe: How do you design this? : with a better example Pin
jschell31-Dec-12 9:10
memberjschell31-Dec-12 9:10 
AnswerRe: How do you design this? : with a better example Pin
Eddy Vluggen31-Dec-12 17:04
memberEddy Vluggen31-Dec-12 17:04 
AnswerRe: How do you design this? : with a better example Pin
Keld Ølykke16-Jan-13 11:23
memberKeld Ølykke16-Jan-13 11:23 
QuestionHow to find the similarity between users in Twitter ? How to design a good and efficient idea? Pin
ldaneil27-Dec-12 7:26
memberldaneil27-Dec-12 7:26 
AnswerRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pin
Pete O'Hanlon27-Dec-12 7:39
protectorPete O'Hanlon27-Dec-12 7:39 
GeneralRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pin
ldaneil27-Dec-12 7:50
memberldaneil27-Dec-12 7:50 
AnswerRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pin
jschell27-Dec-12 9:21
memberjschell27-Dec-12 9:21 
GeneralRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pin
ldaneil28-Dec-12 8:31
memberldaneil28-Dec-12 8:31 
AnswerRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pin
April Fans27-Dec-12 15:43
memberApril Fans27-Dec-12 15:43 
GeneralRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pin
ldaneil28-Dec-12 8:36
memberldaneil28-Dec-12 8:36 
GeneralRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pin
April Fans3-Jan-13 16:46
memberApril Fans3-Jan-13 16:46 
AnswerRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pin
Marc Koutzarov29-Aug-14 23:54
professionalMarc Koutzarov29-Aug-14 23:54 
QuestionClient - Server approach Pin
bugal21-Dec-12 0:33
memberbugal21-Dec-12 0:33 
AnswerRe: Client - Server approach Pin
jschell22-Dec-12 14:11
memberjschell22-Dec-12 14:11 

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
Web02 | 2.8.150731.1 | Last Updated 30 Jul 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid