Click here to Skip to main content
12,512,389 members (67,666 online)

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Connectivity test Pin
MatthysDT2-Feb-12 19:24
memberMatthysDT2-Feb-12 19:24 
GeneralRe: Connectivity test Pin
RCoate5-Feb-12 16:41
memberRCoate5-Feb-12 16:41 
GeneralRe: Connectivity test Pin
Moshe Katz6-Feb-12 14:36
memberMoshe Katz6-Feb-12 14:36 
GeneralRe: Connectivity test Pin
Member 78335217-Feb-12 3:31
memberMember 78335217-Feb-12 3:31 
GeneralThe beauty that is the default conversion... Pin
OriginalGriff31-Jan-12 0:40
mvpOriginalGriff31-Jan-12 0:40 
GeneralRe: The beauty that is the default conversion... Pin
BobJanova31-Jan-12 0:43
memberBobJanova31-Jan-12 0:43 
GeneralRe: The beauty that is the default conversion... Pin
OriginalGriff31-Jan-12 1:01
mvpOriginalGriff31-Jan-12 1:01 
GeneralRe: The beauty that is the default conversion... Pin
CDP180231-Jan-12 1:01
memberCDP180231-Jan-12 1:01 
GeneralRe: The beauty that is the default conversion... Pin
PIEBALDconsult31-Jan-12 2:26
memberPIEBALDconsult31-Jan-12 2:26 
GeneralRe: The beauty that is the default conversion... Pin
CDP180231-Jan-12 2:44
memberCDP180231-Jan-12 2:44 
GeneralRe: The beauty that is the default conversion... Pin
tgrt1-Feb-12 2:56
membertgrt1-Feb-12 2:56 
GeneralRe: The beauty that is the default conversion... Pin
Gary Wheeler2-Feb-12 0:13
memberGary Wheeler2-Feb-12 0:13 
GeneralRe: The beauty that is the default conversion... Pin
RobCroll31-Jan-12 11:11
memberRobCroll31-Jan-12 11:11 
RantEnabling backwards compatibility Pin
Chanoch Wiggers30-Jan-12 2:30
memberChanoch Wiggers30-Jan-12 2:30 
So this is an approach that proved so successful that it was made into a standard. You're writing a shared library and you're concerned to ensure future compatibility across services. Problems include:

* How to support non built-in types? (e.g. MyCustomType)
* How to support float, int, double, etc?
* How to prevent constantly updating interfaces from complicating builds?

Best approach? Well, how about you convert all your arguments into Strings to transfer across the wire and then convert them back.

Every method has the following signature:

public String[] doSomething(String[] args, String userId)

Then you have a static library that allows:

TypeUtils.stringify(Object object); // native types are supported by simply ""+myVar
Object obj = TypeUtils.fromString(String string, String fromType);

Easy. (Note you may need to cast the object returned from TypeUtils.fromString(). User id is there to ensure security, obviously. You don't have to use the TypeUtils but you are encouraged to, for convenience.

This way, when you swap args[2] and args[3], or when you introduce a new argument at the end, you don't have to declare a new version of the interface.

Simply keep the same version interface jar throughout and require everyone to use the very latest implementation.
This is why I don't program

GeneralRe: Enabling backwards compatibility Pin
CDP180230-Jan-12 3:17
memberCDP180230-Jan-12 3:17 
GeneralRe: Enabling backwards compatibility Pin
englebart1-Feb-12 2:42
memberenglebart1-Feb-12 2:42 
JokeRe: Enabling backwards compatibility Pin
Moshe Katz1-Feb-12 11:00
memberMoshe Katz1-Feb-12 11:00 
GeneralRe: Enabling backwards compatibility Pin
jsc4230-Jan-12 3:43
memberjsc4230-Jan-12 3:43 
GeneralRe: Enabling backwards compatibility Pin
Chanoch Wiggers30-Jan-12 4:06
memberChanoch Wiggers30-Jan-12 4:06 
GeneralRe: Enabling backwards compatibility Pin
Firo Atrum Ventus30-Jan-12 11:15
memberFiro Atrum Ventus30-Jan-12 11:15 
GeneralRe: Enabling backwards compatibility Pin
PIEBALDconsult31-Jan-12 2:24
memberPIEBALDconsult31-Jan-12 2:24 
GeneralRe: Enabling backwards compatibility Pin
tecgoblin1-Feb-12 0:27
membertecgoblin1-Feb-12 0:27 
GeneralRe: Enabling backwards compatibility Pin
GamleKoder1-Feb-12 7:56
memberGamleKoder1-Feb-12 7:56 
GeneralRe: Enabling backwards compatibility Pin
tecgoblin1-Feb-12 8:10
membertecgoblin1-Feb-12 8:10 
GeneralRe: Enabling backwards compatibility Pin
Stefan_Lang1-Feb-12 1:42
memberStefan_Lang1-Feb-12 1:42 
GeneralRe: Enabling backwards compatibility Pin
Garry Lowther1-Feb-12 1:42
memberGarry Lowther1-Feb-12 1:42 
GeneralRe: Enabling backwards compatibility Pin
charlieg1-Feb-12 5:52
membercharlieg1-Feb-12 5:52 
GeneralRe: Enabling backwards compatibility Pin
Jeremy David Thomson1-Feb-12 10:37
memberJeremy David Thomson1-Feb-12 10:37 
GeneralStrictly Short Circuit Pin
AspDotNetDev26-Jan-12 15:02
protectorAspDotNetDev26-Jan-12 15:02 
GeneralRe: Strictly Short Circuit Pin
ryanb3127-Jan-12 5:25
memberryanb3127-Jan-12 5:25 
GeneralRe: Strictly Short Circuit Pin
cpkilekofp27-Jan-12 6:40
membercpkilekofp27-Jan-12 6:40 
GeneralRe: Strictly Short Circuit Pin
AspDotNetDev27-Jan-12 7:03
protectorAspDotNetDev27-Jan-12 7:03 
GeneralRe: Strictly Short Circuit Pin
ryanb3127-Jan-12 8:15
memberryanb3127-Jan-12 8:15 
GeneralRe: Strictly Short Circuit Pin
AspDotNetDev27-Jan-12 8:33
protectorAspDotNetDev27-Jan-12 8:33 
GeneralRe: Strictly Short Circuit Pin
ryanb3127-Jan-12 8:47
memberryanb3127-Jan-12 8:47 
GeneralRe: Strictly Short Circuit Pin
AspDotNetDev27-Jan-12 8:59
protectorAspDotNetDev27-Jan-12 8:59 
GeneralRe: Strictly Short Circuit Pin
ryanb3127-Jan-12 9:06
memberryanb3127-Jan-12 9:06 
GeneralRe: Strictly Short Circuit Pin
dawmail33330-Jan-12 0:41
memberdawmail33330-Jan-12 0:41 
GeneralRe: Strictly Short Circuit Pin
AspDotNetDev30-Jan-12 4:37
protectorAspDotNetDev30-Jan-12 4:37 
GeneralRe: Strictly Short Circuit Pin
LetMeFinclOut30-Jan-12 12:36
memberLetMeFinclOut30-Jan-12 12:36 
GeneralRe: Strictly Short Circuit Pin
cpkilekofp27-Jan-12 9:09
membercpkilekofp27-Jan-12 9:09 
GeneralRe: Strictly Short Circuit Pin
Jan Steyn29-Jan-12 23:16
memberJan Steyn29-Jan-12 23:16 
GeneralRe: Strictly Short Circuit Pin
K Quinn30-Jan-12 1:51
memberK Quinn30-Jan-12 1:51 
GeneralRe: Strictly Short Circuit Pin
agolddog30-Jan-12 3:54
memberagolddog30-Jan-12 3:54 
GeneralRe: Strictly Short Circuit Pin
Patrick Fox30-Jan-12 6:07
memberPatrick Fox30-Jan-12 6:07 
GeneralRe: Strictly Short Circuit Pin
ekolis30-Jan-12 10:28
memberekolis30-Jan-12 10:28 
GeneralRe: Strictly Short Circuit Pin
LetMeFinclOut30-Jan-12 12:34
memberLetMeFinclOut30-Jan-12 12:34 
GeneralRe: Strictly Short Circuit Pin
ekolis30-Jan-12 13:06
memberekolis30-Jan-12 13:06 
GeneralRe: Strictly Short Circuit Pin
YvesDaoust27-Jan-12 23:05
memberYvesDaoust27-Jan-12 23:05 
GeneralRe: Strictly Short Circuit Pin
PIEBALDconsult29-Jan-12 4:18
memberPIEBALDconsult29-Jan-12 4: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.160929.1 | Last Updated 1 Oct 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid