Click here to Skip to main content
14,303,528 members
   

C#

 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 15:17
memberBrian_TheLion2-Jun-19 15:17 
GeneralRe: My thoughts on C# Pin
BillWoodruff1-Jun-19 17:40
mveBillWoodruff1-Jun-19 17:40 
GeneralRe: My thoughts on C# Pin
Brian_TheLion1-Jun-19 18:02
memberBrian_TheLion1-Jun-19 18:02 
GeneralRe: My thoughts on C# Pin
OriginalGriff1-Jun-19 20:16
protectorOriginalGriff1-Jun-19 20:16 
GeneralRe: My thoughts on C# Pin
Brian_TheLion1-Jun-19 20:37
memberBrian_TheLion1-Jun-19 20:37 
GeneralRe: My thoughts on C# Pin
phil.o1-Jun-19 22:02
mvephil.o1-Jun-19 22:02 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 16:16
memberBrian_TheLion2-Jun-19 16:16 
GeneralRe: My thoughts on C# Pin
OriginalGriff1-Jun-19 22:47
protectorOriginalGriff1-Jun-19 22:47 
The problem is that you aren't writing a C# program (German letter): you are trying to translate a VB program (English letter) into C# (German letter) by translating each line of code (using a dictionary)
Quote:
You have an inventory class and a get/drop class
Why?
Do you do that in the "real world"? Or do you think "I'm wearing trousers. In this pocket I have a hanky and my small change. In this pocket I have my phone, in this one my wallet. My wallet contains my credit cards, store cards, and bank notes"?

In an object oriented design, you would have an abstract Container class (or possibly an IContainer Interface) which had Add, Remove, and List methods - because just like your trousers, they "know" where to put your phone - left pocket; wallet - back pocket; and so on. And if the Trousers class derives from Container and so does the Wallet class, you remove a card from your wallet (and it's gone from your trousers as well) pay for your sandwich, and put it back.

The idea is that the object knows how to do things that directly affect it: not that you have global functions that manipulate global objects, or a class of "actions" you can "apply" to objects.

Why should an inventory be a global variable? Is there only one in the entire game? Or should "monsters" have one as well so you can "Loot the body"? Think of Oblivion / Skyrim and loads of things have inventories: player, barrels, shops, chests, bags, boxes, bodies, npcs, ... and they are all handled the same way because they aren't globals - they are objects contained in the world.

As I said, translating doesn't produce good code - using the original as a specification does, because you then write good code in the target language. It doesn't matter which language pair you pick: blind translation isn't a good idea.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 15:45
memberBrian_TheLion2-Jun-19 15:45 
GeneralRe: My thoughts on C# Pin
Dave Kreskowiak2-Jun-19 6:10
mveDave Kreskowiak2-Jun-19 6:10 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 15:32
memberBrian_TheLion2-Jun-19 15:32 
GeneralRe: My thoughts on C# Pin
Brian_TheLion3-Jun-19 12:49
memberBrian_TheLion3-Jun-19 12:49 
GeneralRe: My thoughts on C# Pin
BillWoodruff2-Jun-19 20:07
mveBillWoodruff2-Jun-19 20:07 
GeneralRe: My thoughts on C# Pin
Brian_TheLion3-Jun-19 12:40
memberBrian_TheLion3-Jun-19 12:40 
GeneralRe: My thoughts on C# Pin
Richard MacCutchan1-Jun-19 21:46
protectorRichard MacCutchan1-Jun-19 21:46 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 0:15
memberBrian_TheLion2-Jun-19 0:15 
GeneralRe: My thoughts on C# Pin
Mycroft Holmes2-Jun-19 13:36
memberMycroft Holmes2-Jun-19 13:36 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 15:22
memberBrian_TheLion2-Jun-19 15:22 
GeneralRe: My thoughts on C# Pin
Mycroft Holmes2-Jun-19 15:58
memberMycroft Holmes2-Jun-19 15:58 
GeneralRe: My thoughts on C# Pin
Brian_TheLion2-Jun-19 16:50
memberBrian_TheLion2-Jun-19 16:50 
GeneralRe: My thoughts on C# Pin
jsc423-Jun-19 23:18
professionaljsc423-Jun-19 23:18 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 17:48
memberBrian_TheLion4-Jun-19 17:48 
GeneralRe: My thoughts on C# Pin
Brian_TheLion3-Jun-19 12:32
memberBrian_TheLion3-Jun-19 12:32 
GeneralRe: My thoughts on C# Pin
Richard MacCutchan2-Jun-19 21:58
protectorRichard MacCutchan2-Jun-19 21:58 
GeneralRe: My thoughts on C# Pin
Brian_TheLion3-Jun-19 12:44
memberBrian_TheLion3-Jun-19 12:44 

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.