|
yeah, but mate, its all learning
I gave you a '5' for the article anyway, it was up to the usual standard, and just may help someone down the line
|
|
|
|
|
My latest project has been such fun for naming things. It is for submitting property listings (real estate sales) to a web service, but using data I get returned from another web service, so my code's main job is mapping input to output data structures. The required output is a Listing object, for a property, but my mapping code is dealing with lists of Listing properties.
Then, the bulk of data in a Listing object is held in an Attribute array. An attribute is a named value that helps describe a property. But, my property listing properties also have C# attributes. It has taken tremendous effort to overcome the temptation to leave in my wake classes with names like ListingPropertyAttributeList , used in heavily reflection driven code.
|
|
|
|
|
I think you should call a spade a spade. If it's an attribute then call it an attribute.
Brady Kelly wrote: heavily reflection driven
|
|
|
|
|
What's with the over reflection? Must I hard code some 200 assignments from input to output?
Oh, and BTW, you try telling the compiler that "an attribute is an attribute". I didn't choose the elephanting name "Attribute" for use in a .NET class to describe anything but attributes I declare in code.
|
|
|
|
|
Reflection is a tool best used sparingly. If you need it, it's great that it's there, but be sure you really need it.
Brady Kelly wrote: hard code some 200 assignments from input to output
I look for ways to do that and generate code files even before compile time. Not always possible of course, but a Web service shouldn't be throwing surprises at you.
|
|
|
|
|
I normally use it quite sparingly. It's fairly expensive and crosses borders normally in place for god reasons. But this is POC code, so writing a code generator, or even a T4, would take way too much time before I knew it wasn't my data at fault but its destination web service.
The destination web service quite recently built, and still plenty full of surprises. I have no control there.
|
|
|
|
|
Brady Kelly wrote: web service quite recently built
Brady Kelly wrote: full of surprises
|
|
|
|
|
Brady Kelly wrote: normally in place for god reasons Yep, only code GODs dare tread there.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
Did you think of looking at BizTalk? It might remove the need to code at all!
Life is like a s**t sandwich; the more bread you have, the less s**t you eat.
|
|
|
|
|
PhilLenoir wrote: Did you think of looking at BizTalk? It might remove the need to code at all! Sure, if you have 2 years to learn it.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
And bucks to buy it. This is two tasks, one flow code I've written, and the scenario isn't close to warranting anything as big as BizTalk.
|
|
|
|
|
Brady Kelly wrote: And bucks to buy it. Which you can earn back pretty quickly once you have learned it. We had to contract a Biztalk guy for a few weeks to help us out and they are not cheap.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
or you could've used structuremap[^]
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
It is an IOC tool so there has to be reflection or a massive massive switch case.
ISomething something ;
switch(somethingElse){
case 1: something = new ConcreteOne();
...
}
|
|
|
|
|
no, to both.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
Under the hood perhaps. How else would you map interfaces to concrete types?
|
|
|
|
|
with code
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
|
*sigh* why don't you download it and try it out and you'll see what I mean.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
I did. There are 18 instances of Activator.CreateInstance in the code. How else do you think a generic(a product) unity container can work?
I am really curious if there is a way since I use a lot of IOC in my code.
|
|
|
|
|
So this morning I'm testing code I've done for a client to submit property listings to a web service API for inclusion in a popular property sales site, and I notice that a nice little while (true)... loop I've wrapped the API calls in is still in the core code, not the calling code.
I cut and pasted it to around the calling code, and ran the app, expecting my "Hit ENTER to run again, CTRL+C to quit." prompt. Then I was distracted by something, then a bathroom visit, walk in the garden, and some more, before I wondered where my good old prompt was. When I stopped things, I had called the poor (sandbox, not production) web service about 1200 times. Turns out I only copied the loop, not cut, before pasting. But I did cut the code that shows the prompt and waits.
|
|
|
|
|
Well, it's late in the day, we all make mistakes...
At least it was the sandbox, not the production server...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
This was basically the first thing I did today, around 10h00. Haha, yes, I have to send through several OK submissions before they upgrade the client's account for production access.
Their spec notes, "we also noted that we received almost 300k method calls that failed valid business rules", but on the sandbox this morning I found one business rule they weren't aware off: All image URLs must have a ".jpg" extension. They are fixing tomorrow.
|
|
|
|
|
Copy & Past coding?
You copy something but then when you try to paste it you get something you copied 5 years ago instead.
|
|
|
|
|
Oh, have I ever seen that phenomenon on this project. I use Foxit Reader for PDFs, and it really does the job well, except that CTRL+C doesn't copy! And I've been coding off a PDF spec, copying and pasting field names etc. Just a few days ago I was doing it about every twenty seconds. Copy from PDF, paste in code, change in code and copy and paste elsewhere. "Copy" from spec and paste last time's code instead of spec value.
I thought I was going to have to get violent with myself to end the pain.
|
|
|
|