Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Mike E Andrews

@Mike E Andrews
About
Posts
5
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Call for a Professional Programmers' Association
    M Mike E Andrews

    In Black's Law Dictionary, a license is defined as permission to do anything that is illegal, a trespass, or a tort (think about that for your personal day-to-day goings-on). In other words, to do this, bureaucrats must make writing software an illegal activity; and remember, only the "law-abiding" will adhere to the illegality of such a thing - you won't see the scumware, spyware, ransomware, or any number of the other XXXX-ware developers seeking licensure or worrying one bit about it. It also encumbers each and every one of us in ways we can only dream of in our worst nightmares; it would certainly put me out of work. Would it also mean that writing software at home, on your home machine(s) would now be an illegal activity as well? Could you "write software" to teach yourself or learn, but just couldn't accept money for it? Who even knows? Could you be raided by the police for illegal activity? Since you can write software on any computer, anywhere, does now the common person have to have special permission from a government agency to have that computer, iPhone, iPad, or other "smart" device, since it could potentially be used for illegal activity? What about the computer in your new fancy 'fridge? What about all the YouTuber's out there that make instructional videos to teach? Are they now performing illegal activities? What about all the posts here on CodeProject? Are they now illegal? Or do we need disclaimers attached to any example code? And let's not forget game programmers. Are they not then responsible for writing obviously addicting software that causes someone to die because of a 100-hour game marathon with only caffeinated beverages to drink? Or the ones that write the various candy-matching games where someone dumps >$1000 per month to play? It must be because the poor gamer(s) must not bear any responsibility in this scenario. What about the business software developer, the back-end database developer, and the (put the description of the type of developer here) developer? Where would it end? Our livelihoods now come under the purview of any and all bureaucrats with no understanding, comprehension, knowledge, or abilities in this area to make decisions that would crush us. Each state would need a Programmer's Board of sorts, similar to a "Medical Board", that would oversee all of our careers. Others could then "turn us in" for dereliction of duties or for any number of other "crimes" for which we would need to appear before the "Board" to justify our decisions. These ac

    The Lounge question career design help tutorial

  • looking for a business rule engine in .Net
    M Mike E Andrews

    I built one years ago that's still in production today. It was written in C#. The rules are not a custom language or anything of the sort. Each rule is an implemented derived class and each rule has inputs and outputs (which can be anything). Then, you just string those rules together, where the output of one rule connects to the input of another rule. This has two benefits: 1) you don't have the overhead of a custom parser for determining the end-result, i.e., it's already a language you know; 2) you can reuse these rules in various combinations for a variety of tasks. The rules can live in the same or separate assemblies and are then loaded into an AppDomain upon execution. There is a Rule Execution Engine that takes a "map" of how each rule is connected and then loads the appropriate assemblies, from where said rules are located, and executes them in the correct order and asynchronously if needed. This may be a simpler approach than a custom language solution. I do not have a general-purpose one written. I intended to write one years ago (after writing the one for the company I work for), but I never got around to it. This approach may or may not work for you, though.

    The Lounge csharp business question

  • Loop exit
    M Mike E Andrews

    Visual Basic.NET supports similar constructs, such as:

    Exit For
    Exit While
    Exit Do

    and continuations like:

    Continue For
    Continue While
    Continue Do

    The Lounge csharp c++ java delphi algorithms

  • Extension Methods - Satan's favourite construct (controversial to nerds)
    M Mike E Andrews

    Here's one of the problems I see... Extension methods do have their "problems," and yes, perhaps, they are a hack of a sort or an anti-pattern. Regardless, they are very useful for all kinds of situations that makes code far more readable and understandable than its code-filling counterparts with some type of red sauce. The problem I run into with using extension methods is a lot of developers, like a lot of people in general, are just afraid of the unknown and extension methods are the "unknown" when first someone is introduced. I hear all the time... "How will anyone know how to use it especially if they don't know about it?" "We need to program for the Junior Developer so that this code is maintainable later on." "This is too complex for a mere mortal to comprehend." Perhaps all good points, perhaps not, but you get the idea... Here's an example of a very useful extension method that makes implementation code more readable:

    public static IEnumerable AsEnumerable(this IDataReader reader) {
    while(reader.Read())
    yield return reader;
    }

    So, what would you do with it? How about this as a simple example?

    //... Something happened here
    using(var reader = cmd.ExecuteReader()) {
    return reader
    .AsEnumerable()
    .Select(CreatePerson)
    .Where(person => person.Name.StartsWith("B"))
    .ToList();
    }

    Here is the non-extension method counterpart:

    //... Something happened here
    using(var reader = cmd.ExecuteReader()) {
    var persons = new List();
    while(reader.Read()){
    var person = CreatePerson(reader);
    if (person.Name.StartsWith("B"))
    persons.Add(person)
    }
    return persons
    }

    Where is the complexity in this example? Which is more readable? It just gets old that those who really enjoy this kind of work and want to explorer the possibilities are constantly stymied by those who merely want to maintain the status quo. To be fair, though, like most endeavors, you can take it too far. There should be a balance. We shouldn't disdain anyone that wants to use extension methods to improve their code and provide meaningful functionality for others, but likewise we also shouldn't tolerate everything written as extension methods.

    The Lounge csharp functional linq business regex

  • Fastest way to import fixed len file into sql table
    M Mike E Andrews

    As other responders have said, use the System.Data.SqlClient.SqlBulkCopy class. Also, implement your own IDataReader in a class to read the file. The SqlBulkCopy contains a method called WriteToServer which has an overload that takes an IDataReader. Once this is done, you can simply create an IDataReader using a TextReader (via the class you made) and now you can simply read a row and write the row without using a lot of memory with DataTable or DataSet objects.

    .NET (Core and Framework) database question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups