User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Coding Architecture Question Page [1]  
Wolfmarsh
What?
5975 Posts
user info
edit post

For some reason I have a mental block about this and need some brainstorming to connect this in my head...

I have 8 objects that inherit from the same class. They all have a routine that returns another class that acts basically just as a struct for thier return information.

7 of the 8 objects will want to return a .NET DataSet as part of thier arguments, and the 8th will want to return a BinaryStream. (Lets call this part of the return argument struct the payload)

The issue is, i dont want to have this (or some variant) everywhere in my code:

If TypeOf _ReturnArgs.Payload Is DataSet Then
ElseIf TypeOf _ReturnArgs.Payload Is BinaryStream Then
End If

That seems to defeat the point of having all 8 inherit from the base class. Any thoughts?

I am suffering the equivalent of writers block for programmers....


If you need more background on what the classes do to help push through this, I can provide it.

6/25/2010 7:35:44 AM

qntmfred
retired
40817 Posts
user info
edit post

i hate to turn down a good coding question

but if you post this on stackoverflow.com you'll have several answers in less than a few minutes

not that there aren't hundreds of legitimate sites where you could ask this, including tww, but these days stackoverflow is the de facto option of programming questions

[Edited on June 25, 2010 at 8:34 AM. Reason : .]

6/25/2010 8:29:46 AM

evan
All American
27701 Posts
user info
edit post

Quote :
"these days stackoverflow is the de facto option of programming questions"

6/25/2010 9:35:33 AM

Wolfmarsh
What?
5975 Posts
user info
edit post

Thanks, I have it up there as well.

I was hoping that this was just a case of me not seeing the obvious, but I am starting to get a little comfort from the fact that not a lot of good suggestions are popping up in the various places I have posted it.

6/25/2010 9:39:02 AM

evan
All American
27701 Posts
user info
edit post

yeah, i can't really think of much...

except instead of doing the TypeOf stuff, just overload the methods.

(or wait... that looks like VB... you're not using VB, are you? )

6/25/2010 10:18:43 AM

Wolfmarsh
What?
5975 Posts
user info
edit post

VB.NET, yes we are.

If you knock it, you lose a little "programmer cred", imo.

It's just as powerful as C#, and has its place just like many other languages. It's actually not my choice, and I initially turned my nose up at it like a lot of people do, but its the language our shop uses.

6/25/2010 10:31:25 AM

evan
All American
27701 Posts
user info
edit post

oh, i know, i'm just giving you shit.

i tried it but couldn't get used to the lack of curly brackets and semicolons.

everyone has their language of choice.

[Edited on June 25, 2010 at 10:35 AM. Reason : FWIW, i was a complete and total .NET basher up until a month or so ago]

6/25/2010 10:33:39 AM

LimpyNuts
All American
16859 Posts
user info
edit post

IMO the curly braces were a stupid choice for programming languages. Why not use square brackets so you don't have to have your finger on the shift key all the time?

6/25/2010 5:52:05 PM

gs7
All American
2354 Posts
user info
edit post

Because, typically, curly and square brackets mean two different things. They have their uses, but yes, SHIFT gets old, I wish underscore didn't require it.

6/25/2010 5:58:10 PM

Noen
All American
31346 Posts
user info
edit post

you guys know you can remap your keys, right?

I think my solution would be abstract out the payload to be a generic object and then write a class to handle the two types of payloads.

So instead of having that conditional everywhere you want to consume the payload it would instead be calling the payload class, passing the payload which will disambiguate it, parse it and return it as a single consumable (aka output ready char data).

This may not work if depending on the overall architecture (I could see this maybe being a problem in MVC apps for instance, if you care about a strict architecture), but it should work to eliminate the redundant conditional everywhere.

6/25/2010 6:52:52 PM

Wolfmarsh
What?
5975 Posts
user info
edit post

Im getting ready to test my solution now.

I am going to go ahead with bundling the tables up into a dataset just like the other sources would be.

The library I have written already has classes that describe a "virtual db" so i can transfer db structure between machines, that I had forgotten about.

Im just adding that to the return struct as part of the standard procedure.

Thanks for listening to my question!

6/25/2010 7:20:22 PM

zorthage
1+1=5
17148 Posts
user info
edit post

I was going to suggest if the logic is the same but you just need to convert from the dataset to/from the binary stream, override the method, change the data structure, and call the other method.

Though data model consistency is your better bet.

6/27/2010 8:32:39 AM

 Message Boards » Tech Talk » Coding Architecture Question Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.