|
protected void LiveList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
HiddenField username = (HiddenField)e.Item.FindControl("hidden_username");
Image mapbtn = (Image)e.Item.FindControl("mapbtn");
System.Web.UI.HtmlControls.HtmlTableRow tr = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("rowlive");
if (mapbtn != null && username != null)
{
UserProfile selectedUser = null;
selectedUser = Sql.GetUserDetails(username.Value);
if (selectedUser != null)
{
BroadcastOptions broadcastOptions = BroadcastOptions.None;
int sessionId = 0;
if (Sql.CheckActiveSession(selectedUser.UserId, Visibility.IncludePrivate, out sessionId, out broadcastOptions))
{
Location[] locs = Sql.GetLocationByVodID(sessionId);
if (locs.Length > 0)
{
String mapUrl = mViewWebSite.AbsolutePath(
String.Format("/map.aspx?live=true&target_id={0}&uid={1}", sessionId, selectedUser.UserId.ToString()));
mapbtn.Enabled = true;
mapbtn.ImageUrl = "Images/miniWorldMap.png";
mapbtn.Attributes.Add("style", "Cursor:Pointer");
mapbtn.Attributes.Add("onclick", "ShowLocation('" + mapUrl + "')");
}
}
}
}
}
The above code was written by our previous senior web developer (that's what told to me when I was hired).
On every item bound on the repeater he
1) reads the username from hidden control
2) call database to load user details
3) another call to database to check any active sessions
4) another call to load whole list of gps locations to find whether gps is enables or not
5) then finally enable the map button if gps is enabled
Amazingly this list is inside an update panel that updated every 10 seconds
So for an average list of 30 users => total 3x30 = 90 database calls every 10 seconds
when i traced the page it was hauling at 320 Kb every 10 sec.
Fixed this in database, bringing a bool flag back by doing some joins and determining weather gps is enabled or not. Now only 1 db call every 10 sec.
|
|
|
|
|
saxenaabhi6 wrote: Looks like a database call obsession to me…
Come on, that's not obsession.
That's the relationship between boys and their toys.
A hidden needle is way more effective than an unsheathed sword.
That is, in the hand of professionals.
What about you?
Just pray your enemies are blind
|
|
|
|
|
saxenaabhi6 wrote: senior web developer
... and now? retired?
Little bit of a question... was he willing to rethink what've done?
(yes|no|maybe)*
|
|
|
|
|
hehe i dont know...
but i doubt my manager, he might have lied to me that they had a senior developer before, just to save reputation of the company
|
|
|
|
|
The kind of company, that relies more on titles...
(yes|no|maybe)*
|
|
|
|
|
UserProfile selectedUser = null;
selectedUser = Sql.GetUserDetails(username.Value);
You might want to confirm that your KPI isn't based on the number of lines you write.
"You get that on the big jobs."
|
|
|
|
|
We've outsourced some of our dev work, everytime they do something we have to check it because they keep on making mistakes.....
...when testing a change one of the developers made I noticed that the expected change didn't happen.
He said to me it should work, and he's created a unit test to test the change works...
...I then looked at his unit test:
if (order.Allocations[0].TriPartyEligibilityCriteria != null)
{ Assert.IsTrue(order.Allocations[0].TriPartyEligibilityCriteria.Length > 0); }
I had to walk him through this to explain to him just why his test was bad, very bad indeed and it took me over an hour to explain why that was bad and what he should have done instead!
The amount of time we spend inspecting their code and refactoring makes this whole outsourcing exercise a joke
|
|
|
|
|
Suffering in a similar fashion though the code, itself, works most of the time. They are just so untidy.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
Perhaps I'm missing the obvious, but why couldn't that be a valid part of a unit test?
|
|
|
|
|
You could certainly assert the length as part of the test, but the check for null is wrong - you should know if the value will be null or not and do an assertion on that (it may be valid for it to be null, for example if some other property is invalid, but this should be part of the spec).
|
|
|
|
|
I agree it should be part of the spec. There's nothing to indicate in the message or sample that it's incorrect for it to be optional element which can be null. (Only that if it isn't null then it should have a length greater than zero).
|
|
|
|
|
Me (paraphrasing): No, colleague, putting each one of a list of 24 values into its own text box is not an efficient method of data storage. How about putting them into an array, then you can reference them by number.
Colleague: I didn't know about arrays.
Me: (stunned silence)
Colleague: I use goto s to get to the code that reads data from the right text box.
Me: Modern programming recommendations are that you keep usage of goto s to a minimum because it makes determining program flow very difficult.
Colleague: Really?
Me:
|
|
|
|
|
There comes a time when some should consider alternate career paths. I believe the local Burger King is hiring.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
He or his colleague
(yes|no|maybe)*
|
|
|
|
|
Let's just say that somebody should goto Burger King.
|
|
|
|
|
Me, Me,,, I'm hungry
But my boss is staring this way
|
|
|
|
|
And he shall never return ... unless he got some burgers with him
(yes|no|maybe)*
|
|
|
|
|
Ok, you convinced me. I will do that right after work.
"I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011
--- I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011
|
|
|
|
|
Probably thinks he's a data visualization expert.
"You get that on the big jobs."
|
|
|
|
|
Is the colleague actually a programmer? If so, I echo said "stunned silence".
|
|
|
|
|
So it sounds like he has effectively implemented his own array, albeit with poor choices in how to store and access the data, but I think that shows good logic. After all, he doesn't know what an array is, yet he has decided an array style function is the best approach.
He may not have the "experience" of a great developer, but being able to think for himself is a good thing. I think too many programmers are around that just do what the book says, and therefore struggle to be creative when a need arises for something that has yet to be documented.
I may or may not be responsible for my own actions
|
|
|
|
|
If the "colleague" was a high school intern who has never taken a programming class, then yes their logical abilities show promise and they could be trained. However, if this is someone with a degree in programming then they really missed some very basic stuff.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
That is a serious gap in knowledge!
Did this person graduate with a programming related degree.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
The degree bit is not relevant - I'm self-taught, but can read books too. This is really really basic.
|
|
|
|
|
Public Sub SomeMethod()
For Each da As DataRow In myTable.Rows
da(11) = i + 1
items(i) = da(0) & ":" & da(1) & ":NaN:" & da(3) & ":" & da(4) & ":" & da(5) &
":" & da(6) & ":" & da(7) & ":" & da(8) & ":" & da(9) & ":" & da(10) & ":" & da(11) & ":" & da(1)
i += 1
Next
Session("itemTable") = items
End Sub
<AjaxMethod()> _
Public Function GetSessionData(ByVal name As String) As Object
Return HttpContext.Current.Session(name)
End Function
That is some code I just came across (I took out some stuff and renamed some things to protect the innocent). That basically gets information from a DataTable by index (rather than by field name), puts it into a colon-separated-value string (some of the data items include company names and addresses, which could potentially contain colons) that is stored in an array that gets shoved into the session. There is then some JavaScript that calls the server to get that session data (or any session data a client script feels like grabbing).
Luckily, I am replacing this code entirely.
|
|
|
|