Entries Tagged '.NET' ↓
July 18th, 2007 — .NET, Code, PHP
Today, like most days, my day was spent solving problems that were not mine to begin with, but became either too complex or the person just needs someone to hash it out with. Either way, I enjoy these opportunities.
The majority of problems start with the lack of analysis, or the complication the analysis turns up. This afternoon, I was meeting with one of our tech system guys going over a support issue we received when a co-worker dropped by to hash out his new issue, which brings me to this blog post.
Analyze, Analyze, and then Analyze again! Analysis is a major part of every project and it something that should be taken seriously and completely is at Central (where I work). My co-worker had done quite a bit but had major questions about the project and the path he found best so far, primarily, would the data set he wanted to achieve be too large to handle efficiently. So, considering one of our tech system guys was already at my desk, and I am a bit of a SQL genius myself, we hashed it out.
We estimated that in the worst case scenario we would be approaching 15 MB of data, which is fairly large. However, during our discussion we also established that the data would only need to be pulled out of the database once per day. Now that is very important! Think about it, 15 MB is nothing if all you need it is one time. If you have to call it 25 times a day, that makes a hell of a difference.
However, the code path my co-worker choose would have made him pull out the data 25 times. Analysis with others, or re-analyzing your project due to the questions you are left with should be taken seriously. If the data your application is going to use will never change for 24 hours, then program it so it take advantage of this tidbit. Persist that data outside of your storage solution to reuse throughout the day so you do not have to hit up the server to retrieve that data over and over again (in a sense, cache it).
If the data might exceed a decent size to cache (ie: 15 MB), then write it to a flat file and open, read, and close immediately thereafter. That way, you still only pull the data from SQL Server once, and for the remainder of the day you work with the flat file.
By all means, keep your co-workers informed and when questions arise, talk out your solution with them to see if they have any better ideas, or agree with your approach.
July 13th, 2007 — .NET, PHP
I can’t say this often enough, SEPARATE YOUR DESIGN AND YOUR CODE! If you want easy maintenance, if you want to be able to change your design and not have to recode a LOT of things, SEPARATE THEM!
This evening Mark and I were having a bit of a debate, he was asking how to execute .NET code in the HTML designer, and I personally wanted to say “It’s not possible”, but went ahead and told him to use < % code here %>. Of course, I then proceeded to warn him of the danger that will present in the future and the fact that it is bad practice to do such.
So let me explain to everyone why it is necessary to separate code and design.
- Reusability
Let me present fact number one, by separating design and code, you are forced to write code in a more reusable manner. For example, with the separation you are likely to write a placeholder on your page, that you will use the CodeBehind page to write the output (or for PHP, in a class you call).
Now the idea is to build an object for your data, something that can be reused by numerous applications. Yes, I know what you are thinking, this data will never need to be reused, why can’t I just write the code in the design? You say it can’t be reused now, but just give it a few months and when someone asks how to access your data, you will feel pitiful. ALWAYS write your code as if everyone would want to use it! Anyways, you have your object of data, and then it is up to each application to determine how they wish to display it. Thus, if you do not incorporate it directly into the design, it is entirely reusable in any fashion, form, design, etc. Thus point number 1.
- Maintenance - Updating
By placing your code in a separate file from your design, you can achieve easy maintenance and updating of the design without having to rewrite significant pieces of code. How site designs has your company been through? Are they looking into going into Web 2.0? Will they likely rebrand if bought? Will users complain about the complexity of the design and seek an alternate way of access their data? All these are things to consider at design time and at code time.
How cool would it be if all you had to do was alter the CSS and the HTML to implement the new design, all of this is possible when you separate Code and Design. At work, our sites are made just like that, and I am damn proud about it too. The fact I can just a few lines in the stylesheet and show off an entirely new looking site just rocks! Unfortunately, very few know this and every so often write code that doesn’t quite flow with what I try to achieve.
- It’s Easy!
Why not separate design and code? If you are using Visual Studio for .NET, you are an IDIOT not to separate them. Visual Studio makes it easy! Binding objects, datasets, etc to just about every possible control you can think of, and you aren’t doing this. You think it is overkill? Well its’ not. It was designed this way intentionally to ensure the practice of separating design and code get utilized into your coding lifestyle. So if you feel it is overkill, GOOD. You are doing exactly what the developers of Visual Studio wanted you to do.
There are many more reasons, and everyone typically has a personal reason for separating code and design, what are yours? Why do you do it, or not do it?
February 1st, 2007 — .NET, Code, Work
For anyone who has developed in .NET using Visual Studio, I am sure you probably have heard of CodeRush. Well, I personally think this addin is a PIECE OF CRAP! The thing hogs memory like no other and can leave Visual Studio sitting there for 30 seconds or more doing nothing! I can write a A LOT of code in 30 seconds and I do not like to wait.
Now, I know what you are thinking. You have too many of its features enabled. Duh, it will be slow, it comes with nearly everything in it enabled. But you are wrong. I have disabled nearly everything! I disabled the Smart Copy/Paste, the Smart Return, the Templates, the Hints, EVERYTHING except the Flow indicators and the line counting per method (that is just a nice feature). However, whenever I do a copy paste, it acts like the Smart Copy/Paste is enabled and it takes 2-3 seconds before I can move the cursor again!
So just to warn everyone, CodeRush can cause you to actually be less efficient. You will sit and wait for you to be able to move the cursor again for countless seconds. Take it from me, it isn’t worth it and its definitely not worth $250.00!