Skip to content

The Weird and The Wonderful

It was the best of code, it was the worst of code. Coding Horrors, Worst Practices, and flashes of brilliance

This category can be followed from the open social web via the handle the-weird-and-the-wonderful@forum.codeproject.com

1.8k Topics 20.7k Posts
  • O_O

    question csharp html adobe architecture
    2
    0 Votes
    2 Posts
    0 Views
    enhzflepE
    Perhaps you'd find some of the questions at Programming Puzzles & Code Golf Stack Exchange[^] some fun too. First thing I thought of when seeing the source-code formatted like that.
  • Sometimes I question my own sanity

    question
    14
    0 Votes
    14 Posts
    0 Views
    R
    "I don't think I've ever read a class name with 30 characters before." I find that hard to believe. They seem a common occurrence to me. "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
  • Quick! Someone send me an email!

    com tools
    3
    0 Votes
    3 Posts
    0 Views
    L
    If you would be so kind to publish your address here I would gladly help ... as would millions of others ... that said, (sub)empty inbox would bother you no more ;)
  • Docking and Anchoring

    com debugging help question learning
    4
    0 Votes
    4 Posts
    0 Views
    C
    Anchoring is not use in WPF. Docking is used if you use a DockPanel.
  • 42 method

    ruby html json
    6
    0 Votes
    6 Posts
    0 Views
    N
    I strongly suspect that the event function just contains: stdout << "I'll have to think about it."; Thread.Sleep(189345600000000000); sdout << "I have it!"; "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli
  • Why?

    database csharp sql-server linq sysadmin
    15
    0 Votes
    15 Posts
    1 Views
    Richard DeemingR
    Not with Entity Framework. The placeholders in the query are replaced with parameter names, not the values passed in to the method. Tracing through the code, you eventually come to the System.Data.Entity.Core.Objects.ObjectContext.CreateStoreCommand method. The relevant part of the code looks something like this: if (parameters != null && parameters.Length > 0) { DbParameter[] values = new DbParameter[parameters.Length]; if (parameters.All(p => p is DbParameter)) { for (int i = 0; i < parameters.Length; i++) { values[i] = (DbParameter) parameters[i]; } } else { if (parameters.Any(p => p is DbParameter)) { throw new InvalidOperationException(...); } string\[\] parameterNames = new string\[parameters.Length\]; string\[\] parameterNamesWithPrefix = new string\[parameters.Length\]; for (int i = 0; i < parameters.Length; i++) { parameterNames\[i\] = string.Format(CultureInfo.InvariantCulture, "p{0}", i); parameterNamesWithPrefix\[i\] = "@" + parameterNames\[i\]; values\[i\] = command.CreateParameter(); values\[i\].ParameterName = parameterNames\[i\]; values\[i\].Value = parameters\[i\] ?? DBNull.Value; } command.CommandText = string.Format(CultureInfo.InvariantCulture, command.CommandText, parameterNamesWithPrefix); } command.Parameters.AddRange(values); } So if you pass in the parameter values, rather than DbParameters, the code will automatically create parameters called p0, p1, etc., and insert the parameter names into the query. "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • Cultural mess

    design hardware help question
    4
    0 Votes
    4 Posts
    0 Views
    N
    Bernhard Hiller wrote: That's the first time I was faced with such a mixture. And thus I learned to ... That's the most important thing M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
  • My father is a genious

    adobe
    19
    0 Votes
    19 Posts
    4 Views
    V
    sorry its hard to be trilingual
  • Did I miss a memo?

    question
    20
    0 Votes
    20 Posts
    1 Views
    S
    VB sucks. This is the underlying truth. I've been dealt with it. Now cleared that garbage with .NET bleach called GC. :)
  • Found in old code

    19
    0 Votes
    19 Posts
    3 Views
    J
    That only applies to objects. For instance... var a = 'howdy'; var b = a; a = 'partner'; alert(b); // shows howdy var x = {message: 'howdy'}; var y = x; x.message = 'partner'; alert(y.message); // shows partner And even if that was the coder's intent, it would still be way more readable to do something like this... var a = 'blah'; var b = new String(a); a = 'yo'; alert(b); // shows blah Jeremy Falcon
  • Because Reasons

    help question
    19
    0 Votes
    19 Posts
    2 Views
    B
    Located the interface (INavigatableControl) and the method now takes a NavigatorButtonType enum as the parameter. At least it isn't stringly typed anymore. What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
  • From the mouth of the Javascript developer

    csharp swift javascript python ruby
    7
    0 Votes
    7 Posts
    0 Views
    B
    Those cow-orkers were complete idiots. And JavaScript is a back-asswards language that needs to be replaced with something that actually makes sense. What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
  • NotImplementedException not implemented

    13
    0 Votes
    13 Posts
    1 Views
    S
    You clearly need to write some unit tests for your unit test :)
  • SA1122 : CSharp.Readability

    csharp tutorial com tools help
    30
    0 Votes
    30 Posts
    1 Views
    L
    sibling123 wrote: From my point of view string.Empty conveys the intention that the string is not to be null and have no characters. So do two quotes. sibling123 wrote: Seeing a magic value like "", Two quotes are no magic value, but a global constant expression. sibling123 wrote: I will try to avoid that, or use a const value. Duh. SA1122 is simply nonsense. Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)
  • Another great loop idea

    4
    0 Votes
    4 Posts
    0 Views
    Sander RosselS
    That makes sense in the given content :) void DoNothing() { Iterator i = foos.iterator(); while (i.hasNext()) { i.next(); } } Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject. Simplicity is prerequisite for reliability. — Edsger W. Dijkstra Regards, Sander
  • PostgreSQL RAISE

    html postgresql
    2
    0 Votes
    2 Posts
    0 Views
    R
    Actually looks like a pretty standard approach for SQL databases. The SQLSTATE stuff is supported by Postgress, MySQL, MariaDB, SQL Server, surfaced by ODBC, DB2, etc. It allows a query or procedure to return errors and/or informational messages. An error indicates processing could not complete, and informational message may, for example, warn of data truncation but allow the task to finish. "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
  • Don't know whether it's weird, or wonderful

    12
    0 Votes
    12 Posts
    2 Views
    N
    Im working at Japan, so 1 day my task is review some code of the internship, and he naming variables with Kanji (im not Japanese). Its like a pain in the a.. :doh: In code we trust !
  • Lets make sure, shall we

    ruby question
    7
    0 Votes
    7 Posts
    1 Views
    N
    May be this poor guy think that check test_fn() 1 time is not True enough, and he do it twice just for sure :-\ In code we trust !
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • loops and stuff

    8
    0 Votes
    8 Posts
    0 Views
    raddevusR
    I believe Brisingr is thinking of when you iterate through a enumerable and you attempt to update the ienumerable item. Like the following: for(String s : stringArray){ if(i > 0){ // if you attempt to update the s var. s = joinCharacter + stringArray[i]; } i++; } It's fine to update the other referenced collection (stringArray[i]). Brisingr probably was just thinking about that. Not trying to start a battle by speaking for him though. My book, Launch Your Android App, is available at Amazon.com.