|
|
Mood: The Grumpy Coder
-
About last week, I got very strange traffic in my inbox. On Sunday, I got an email from Ernst asking if the rumour that I live “[and work]” in Durban. I replied. Precisely 12 hours later, I get an email from Stuart. What do these guys have in common? They are the Durban leads for the www.sadeveloper.net site.
After getting to chat a while, I found out that Ernst was an MVP. It was like... cool! I knew that some people in South Africa got the MVP title because I do follow some stuff at www.sadeveloper.net from time to time. However, it is extremely ironic that Ernst lives more than 40+km away from me (straight line... nevermind the travel around the harbour) but he works only 3km's from where I live.
So he suggested/invited me to pop in to his place of work so we could talk about me getting involved in the local user group. (Only a few people knew what happened but this blog post is not about what was discussed). I think it was pretty cool being in presence of another guy whom was a geek. Because my school is closer to his place of work (one kilometer away), I popped in on Tuesday.
I think that moment was the most terrifying / nerve-wracking / embarrasing moments of my life into one. I went to woman who opened the door to ask “what business I had to do over there” (ok, she did not phrase it like that but the LOOK :-)). Sure, I followed her to a room like seven metres aways and she says something to Ernst. Because I was standing outside, I did not know who “Ernst” was so I walked in and I saw six or eight guys standing around in the partitioned office. I then forget his face that I saw over MSN so I thought, “what are the chances of one of them being Ernst?” So I responded “howzit, Ernst!”, only did Ernst pop up from behind the partition. I must have gone semi-tanned white to blood red.
I met quite a few guys -- I remember the name (and face) of Grant because I asked for his name twice (did not hear the “G” the first time). I think the other guy's name was Sean (or Shawn -- why they spell the same name differently, I have no clue). We went to the conference room next door and talked for about 15 minutes. (We had to make it short because he had to get a milestone out). From that, I learnt the following:
- For some strange reason, I can't talk geek-jargon in a speech that fleuntly.
- The classical -- learnt how they really pronounced “Yukon”.
- Ernst has a good idea with the fun-community get together (I am not going to say what because we have what the Capetonians don't have).
- Ernst is really keen on Yukon.
He offered a lift home... so I accepted. I think that was more embarrassing than anything -- on they way, we were still continueing our conversation that I forgot to give him directions. Eventually, I started to use hand-signals when the turns came up.
Ok, ok -- it was a cackling experience! But good to finally meet you face to face, man. Now Stuart in my gunsights now... and that is all sorted out as I will be going to the Pattern and Practices session this Saterday.
PS: I heard the comment in the background from one of you okes “whose the kid?”
|
-
Why is it that when a piece of code that you have issued to the public, for free, is attributed as a bug? I mean, let's look at a comment that I got in my e-mail box for a simple article that demonstrates on how to keep scroll back position over post backs.
Thank you very much for this control, there's only one bug when I use a DataGrid + nested ASP Repeater, the problem is because I use a CheckBox to display the Nested ASP Repeater so with your control it doesn't scrolls down well because it only counts the pixels (rows) the first time the page is loaded so when it is refreshed it doesn't returns to your exact position.
Ha! So what was commented to me is that the “exact” is “absolute”. Then, by those definitions and exactly what was discussed as the cause of the “problem” is well... is keeping consistency of “absolute”. Behind the scenes, all the server control is interested is how many pixels the browser has scrolled by.
However, I do get the “just” of your problem. I bet you that you are inserting controls above the checkbox -- which should take UI space on the browser. To resolve that problem, relative recordings of the controls that caused the post back will have to be computed. On top of that, the event model for older browsers are flawed -- something that I wanted to avoid patching around. I am not a brute force type of guy.
But as it stands, my server control is accomplishing exactly what it was designed to do. Therefore, you cannot just call this a “bug” if it does not do what it was designed to do in the first place.
|
-
This has become a FAQ over the time and so I have decided to just write a darn blog post about it.
With collection management during design-time is fairly easy. In fact, too easy. However, sooner or later, you would like to have a multi-dimension collection. Let's take for example:
[ParseChildren(true, "Tabs")] [PersistChildren(false)] public abstract class Menu : Control { private MenuItemCollection _MenuItems = new MenuItemCollection();
[NotifyParentProperty(true)] [PersistenceMode(PersistenceMode.InnerProperty) ] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public MenuItemCollection MenuItems { get { return this._MenuItems; } } }
public class MenuItemCollection : CollectionBase { public new MenuItem this[int index] { get { return (MenuItem)base.this[index]; } } }
public class MenuItem : Menu { // ... }
public class MainMenu : Menu { // ... }
One common trait that will build up is the MainMenu control will have the Menu property which will open up a designer to add MenuItem instances. No big deal! However, your menu items also has the Menu property which will open up another designer. So you can add menu items within an menu item. You think that you are finished so you accept the changes and close the designer only to be met with an error message “object reference is not set to an instance object”.
The cause of the problem is very vague. However, let me tell you a little secret -- the problem is not with your code; it is with Microsoft's. Luckily, you can override their designer for the collection management and just put enough effort into the designer to make that pesky error message go away. So, here is the code for the new, overridden designer:
public class MenuItemCollectionEditor : CollectionEditor { private CollectionForm collectionForm;
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((collectionForm != null) && (collectionForm.Visible)) { MenuItemCollectionEditor editor = new MenuItemCollectionEditor(CollectionType); return editor.EditValue(context, provider, value); } else return base.EditValue(context, provider, value); }
protected override CollectionEditor.CollectionForm CreateCollectionForm() { collectionForm = base.CreateCollectionForm(); return collectionForm; }
public MenuItemCollectionEditor(Type type) : base(type) { } }
If you had to look carefully at the code, you will eventually find out that the cause of error message was because only one designer instance can be “open” at any given time. The above code just rectifies that so that it creates multiple instances of the designers.
To use the above code, just pop the following attribute on the collection:
[Editor(typeof(MenuItemCollectionEditor), typeof(UITypeEditor))] public class MenuItemCollection : CollectionBase { // ... }
|
-
I am furious! Until recently, polotics has not been my thing but now I am back! I just logged on, got my email and did my things with the emails. I planned to spend about 15 minutes here and when I finished doing all of my responding and filing, (without reading a single .NET article ), I had five minutes to spare. So why not just go read the newspaper soon as I have been focusing so much on my studies? The first head line that I came across was:
Strike threat could wreck matric exams The country's [South Africa's] top education official has warned that a full-blown public service strike would have "a very detrimental effect" on matric examinations next month.
Here is my deal on the thing. Teachers are rewarded as per their performance. If their students get their matric (a high-school pass) and maybe excellent set of results (such as getting a exemption -- to qualify for university), they will get rewarded. Getting an average of a 2% raise for each year (taking that if you are a good teacher) is way above the inflation rate and interest “mount-on” rate. In fact, all we are seeing now is the interest rate is alternating between drops and staying the same. Yes, maybe the start-off salary should be a little higher. However, if you do not perform as a teacher, you cannot expect a raise to be issued. In fact, if you don't get a raise for five years in a row, it would be the ideal time to hop onto a new carreer path -- you are not passing on knowledge to the students.
With that said, do I think, in general, teachers' pay is suitable? Definitely. But now, I am sick and tired of the “vast-majority” (to be politically correct) blame all their “misfortunes” onto the government and apartheid (for those whom do not know South Africa's history, it officially ended about a decade ago and it is basically is like dictatorship government where “whites” were supreme). For the last year, we have been proclaiming for a decade of a democratic government. Let's break the word democratic by dictionary definition:
Pertaining to democracy; favoring democracy, or constructed upon the principle of government by the people.
We, from the above quotation, are the “people”, right? So are the “vast-majority” group placing burdens on the rest of the people... not the “government”. The founding for this is “guilty”. And here is what arrogrance I found in the newspaper:
On the potential negative effect on matric exams, Cosatu spokesperson Patrick Craven said yesterday: "Clearly this is something we would want to avoid, but the responsibility for any harm done must be placed firmly at the door of government."
Listen pal! You had your way with the Durban Metro Solid Waste where you polluted the entire Durban region and the threat of disease was close... actually, a shave! I will not bow down to you -- are you saying that I must forfeit all the effort and hard work so you can get the non-performing teachers to teach.
Here is the deal that I had from personal experience -- if the teacher can't teach, he/she is useless and redundant... just like any other office worker. I refuse, as a year-away taxpayer, to pay for the non-peforming teachers and for you to try and jeopodize my future. If your threat becomes the reality in a month, I have effectively wasted:
- Two years of my life. (The year that has to be made to “catch-up” and the year that I have to sit again)
- Four years of maximum potential pay. (The two years wasted for school plus the two years to catch-up in contrast of what should be the ideal timeline).
Sure, I said that I will be moving onto my own company at the end of this year. In fact, I will meet that commitment and goal that I have set -- I have already started initializing the deals so on day one, I am busy. If you jeopodize that, my 'friend', are you going to be prepared to pay the lost billion+ rands (local currency) that the economy will lose because of your actions? All you have to do is hold your negotations during December where no scholar will be affected... we have worked hard for our matric. And I don't want to hear the “eish! I do na know. I don t hav a matric. I do n't know how will affect you.”
|
-
Want an invite to Gmail? I have four of them to give out. Contact me at grumpycoder@gmail.com or just leave your information in the feedback section.
|
-
One of things featured in the Alpha (Preview Release) is Pagination. How pagination works is the use of the ExecutePageReader method from the DbCommand class. In the Beta One release, the ExecutePageReader method is now obsolute. With the pagination, you can query what section of the data can be read from database. For example, you can say that you want records 20 to 40 from any given table.
However, it used SQL Cursors. This method is SLOW when used on huge tables. So Microsoft decided to leave it and move on. However, there is a technique that has been in my “books” for a long time is the following SQL Query:
Select * From (Select * Top RowCount From ( Select Top {StartRow + RowCount} ColumnsToSelect FROM TableNameOrFurtherSelect [NormalStuff] Order By NormalOrder ) Order By OppositeOrder) Order By NormalOrder
There are a view variables that I italiced and bolded. I will discuss the normal stuff below:
- RowCount: Is the amount of rows to be returned from the database table.
- StartRow: The row index to start the selection from. This is used in the sum with RowCount in place of the {StartRow + RowCount} -- treat it as one constant; not an equation.
- ColumnsToSelect: Your normal columns to select from the table.
- TableNameOrFurtherSelect: This is basically one of the two:
- The table to select from.
- The query to run on other tables. This query must be encollapsed by brackets.
- NormalStuff: Things like WHERE clauses and such all goes here.
- NormalOrder: Well, this the trick to magic. Basically, you would know more or less the order of the data that is going to be played to you. For example, if you don't really do any sorting, you know that the order of the records/rows will be recieved in Primary Key-Identity Order.
- OppositeOrder: The complete reverse order of the NormalOrder. For example, if you NormalOrder was “Column1 ASC, Column2 Desc” then your OppositeOrder will be “Column1 Desc, Column2 Asc” and so forth.
Hope you guys and girls learnt something. If any of you have other ideas or tricks that you want to share for pagination, fire them my way. The only thing that I will be “over the moon” is for faster ways to do the selection process on the SQL Server.
|
-
I was *just* about to write a huge article on the new page lifecycle for ASP.NET 2 when I ran across this diagram. I guess that a picture can describe more than a thousand words.
|
-
Humour post on the way :-). I think that you should read this first before reading the rest of this blog entry. Who wants to know what the proof of design concept? Come'on! It is rather easy.
The prototype for that design was to wrap duct-tape... instead of the elastic band.
|
-
... where computer viruses that live and breed in a very “stable” enviroment. For the last two or threee weeks, I have been working “on and offsite” with the school's computers and every single time, I can garentee you that a virus has really mucked up my:
- Compiler
- Compiled versions of my source code (for instance, Jeefo.A virus).
- Rewritten some source code.
Luckily, I am using CVS to track changes and compare source code versions. Managing a 70000 line project is really tough work for one coder who is under constant threat from viruses. There must be at least 20 infections on the machines that I work on... and they are the “best” ones off.
The school has just gained a further 28 machines which has Windows... wait for it... XP. Not even a service pack or a patch has been applied as of yet. I can bet you that those machines already have lost their virginity!
Today, I think I was experiencing a mismatch of compiler and unit files for Pascal. I did not have enough time (with my very limited rights) to give a diagnosis to the problem. It is crunch time -- I should have finished the project as of now but I have been stuffed around too much by those viruses (mainly due to those viruses have stuffed my compiler).
It will be just my luck if all the machines fall over tomorrow. The project is due tomorrow. I have already jeopodized the all-nighter by having a hot shower -- feeling tired, feeling tired. I hate the feeling that I am “trapped” and controlled by things out of my control... which could have been if they listened to my advice. If something goes wrong tomorrow which is out of my control... I am going to BLAST someone.
|
-
[me.exe /sarcastic=true] First of all, I would like to thank every single one of you whom submitted ideas. I would like really extend my gracious thanks to everyone who also got an idea in their head but never told me... [me.exe /sarcastic=false] but only if there were at least one submittion so I can thank someone!
That is no flop. Really! I can live with it. Basically, I am heading into a little hazy weather; that is all. But I have been armed with a compass with a new oppurtunity that has presented itself which I opted for immediately (well, no sarcasimn here: thanks Teemu Keiski for this oppurtunity).
Update: I know that the comment left by Kay Lee was yesterday but this is the first chance that I have really had to reply. Basically, the “ideas” that I am looking for is actually what you see as an opening in the market -- something that is needed or can be done at a higher quality... something that you think that will sell. It is sort of a market research thing but there are rewards for feedback.
|
-
Whoaa! I have been dreaming for a day like this for a long, long, looonnng time. I have just 15 more retarded days to spend with Pascal. After that, I just have to write some documentation on one of my Pascal projects; which I can do within two or three days.
All I want to do now is rock my body in celebration. HOWEVER, guess what I have in 15 days time as well? It is the start of my second to last sprint of exams! Why am I excited -- I have been preparing for those exams for the last two months.
I do not know but 114 days until the very last exam I have to write seems to be a very short time... and I just got a SMS from a friend wishing me luck for the last stretch of school life. How ironic!
What am I going to do on the day that will come in 115 days time? Ah -- nothing much ;-). I will give some more specific details later in the year... Ok, I will drop a *strong* hint -- has anyone got any ideas of what .NET or ASP.NET component or off-the-shelf-product they would like to be developed? I am not being lazy -- I have a whole bunch of ideas to be executed within the next two to three years. I am just trying to do research so that I can fine tune my “initializing” plan.
I am all ears on what you have to say. Maybe there is a reward if your feedback is valuable.
Update: Ok... I don't think that I sound serious. If I told you that I was dead serious? I just won't say what the reward is as of yet because depending on how helpful your suggestion is, the higher your reward is going to be... but I am not going to tell you the lowest and highest limit.
|
-
I am back! Ok, down to business -- we have all seen/heard (or done) moaning of converting C# code to VB.NET code. So there pops up a few conversion tools for converting C# to VB.NET code! But did anyone even consider the C# guys wanting a tool to convert all the VB.NET code to C#?
I do not think so. However, there is something that was hiding underneath one IDE -- #Develop. I found that tool when I downloaded the Beta RC2 and just “happened” to see that menu item. That is so cool!
|
-
Ernst had a little maths quiz that had three doors and two chances. I wanted to add another quiz that had to do with doors as well:
You are in a room with two doors, A and B -- the one door leas to freedom and the other doot will take you to a gruesome death. You are allowed to leave the room but you will have to choose the right door. There are guards at the two doors. The difference between the two is the one lies all the time and the other one only tells the truth. The twist is that you do not know which one lies or which one tells the truth.
You are only allowed to speak to one guard and ask one question. How are you going to discover which door leads to your freedom?
I would also like to build a list of 'smart' solutions. I made a whole list of them and I am sure someone will say:
Ask the guard to go through the door which leads to freedom. (In other words, you will make the lair truthful BUT the problem is that it is instruction; not a question).
|
-
Right! Bringing out the big guns! Jeff blogged about why the LoginView of ASP.NET Whidbey “sucks”. I do not think that he has any experience building custom server controls. In a follow up blog post he made, he said:
Some might argue that it's like the controls you create in a grid or repeater, but this isn't like that at all because you'll never have the same template rendered more than once in a LoginView.
Ok, fair enough in terms of accessing the items. But what about the HeaderTemplate and the FooterTemplate? They only occur once and sometimes, you have access what is in that part of the page. I dunno', that argument that Jeff presented at that point seems kind of invalid but I will call this redundant argument because of what I have to say at the end of this blog post.
However, he did present a good basis of his point when he said the following:
Every ASP.NET developer has been there before. Some sections of a form should be shown to some people or anon users.
Ok, not every developer -- you get your administration back-end pages and your public pages. That is under “normal” circumstances where the user either have the rights to edit the content or they do not. However, I must agree to the point (no matter how much emphasize or exaguaration has been put on a minor point) that there are times that you want to just show some extra UI to the certain people who has certain rights.
But what I really got pissed off at the fact that Jeff never looked any further than “It is by design.” First off, I want to say that is part of the design of the templating system. That is how far it goes; however, the templating system does provide some leverage.
Again, I said in my comment of Jeff's initial blog post is:
The better solution instead of waiting for the PreRender stage of the life cycle to come by is to migrate the controls into custom templates, port it into an user control or port it into a server control.
Ok. Maybe I was not specific enough. I have written an article before on the basics of the templating system. Have a read though it and you have the following options at your disposal:
- Set custom templates on the LoginView control via C# / VB.NET code (programmactic).
- Have a user control encollapsed in the template.
- Extend the LoginView control to tailor for custom needs. This will require a lot more work and I would recommend #2 over this one.
There is just one part of Jeff's argument that I would love to though into the trash:
Postback events have long since fired. Honestly, how is this useful? Some might argue that it's like the controls you create in a grid or repeater, but this isn't like that at all because you'll never have the same template rendered more than once in a LoginView.
Maybe the events have been fired long before for other controls outside of the LoginView control but have you ever heard of “controls play catch up to the current status of the page life cycle?” For example if I had to add a control to the page whilst the page is in PreRender stage, then my control will then go through (in chronological order):
- Init
- Load
- PreRender
If there there was any kind of post back events, they would fire just after the Init and Load events. (That is, depending on the type of interfaces implemented on those controls). I have already gone through this in an article that I have also written (I pointed to the page that would be of more relevance to the subject).
However Jeff, if this was possible (I gave the proposed solution in that blog post in detail; I am not talking about the hack), then I would totally agree that there is a better approach.
|
-
This is a true geek. Puts a whole new facet to art... and you must see how digital it is. Other than that, I have no comment -- my jaw is still on the ground.
|
|
|
|