Kinetic Code Camp - Bring your skills, or lack thereof.. :dumpster_fire:

Welcome to Code Camp!

:fire: :dumpster_fire: :fire:

Please bear with me while I reserve a few posts and get some content in here.

Continuing from here: Any Interest in a Coding Camp Type Thread?

There seems to be enough interest in this, so I am going to get it started.

In this thread we will both lay out some pre-defined topics, as well as answer questions. I encourage you to still ask questions in the main forums if your question is very specific and needs more help. This thread will probably tend to be a bit more generic, but not always so.

This will be a free-for-all :dumpster_fire: , but we will try to organize the top posts with a curated list of the good stuff.

RULES:

  • Do not volunteer anyone to help with this except yourself.
  • Tagging someone is ok, as long as itā€™s within reason.
  • No pestering people.
  • You can occasionally bump the thread if you think weā€™ve forgot, but better yet, ask a new question!
  • Itā€™s ok to ask stupid questions. If we chose not to answer, just know we are judging you, but quietly.
  • This is not MY thread, itā€™s Your thread. But if you ask ME to do widgets :poop:, you will be treated with severe disdain, possibly insulted, and quite possibly asked to leave. Ask anybody else, thatā€™s fine. :rofl:
    @josecgomez is not coming to your rescue, unless your post is in the correct font, size, clear, and very brief. It must also take less than 5 minutes to answer.

Wiki Posts are one post down.

23 Likes

Topics: (Bear with me, Iā€™m no professorā€¦ No particular order!)


  • LINQ - Language Integrated Query ā€“ (Iā€™m gonna need help with this one, but itā€™ll be fun)



  • BPMs (Method Directives)

  • BPMs (Data Directives)

  • UBAQ BPMs (Method Directives)

  • DataSets, DataTables, Oh My!

(Answered) Questions:



  • Level ā†’ CS300 (Advanced)
    • None Yet


.

(Proposed) Questions:

  • What the #$@! is a RowMod?

  • How can we guilt volunteer someone to help without breaking the no volunteering anyone rule?

  • When do you use a Method Directive vs a Data Directive?
    :hammer: vs mc hammer rap GIF

  • What is the difference between In-Trans and Post-Trans, Pre, Base and Post?

.


Relevant Links & Resources:

6 Likes

Winnie The Pooh Cartoon GIF
System Design & Architecture (@Mark_Wonsil Corner)

  • Post reserved.

Project Examples:

  • bɘĘØÉæɘvɘŠÆ ɈĘØoŌ³

Video Resources

Tools

1 Like

Post Malone:
Cheers Ice GIF by Post Malone

2 Likes

What is a Func<T> or an Action<T>?
How is it useful?

Inside BPMs, UBAQ BPMs, or Epicor Functions (BPMs who drink wine with their pinky out), you are inside a single method call. So you cannot define your own methods inside like you could in a traditional class based system.

That kind of sucks.

There are a few workarounds for organizing your code, and the items we will discuss today will be helpful to work around such limitations.

Ok so what are they?

Technically, they are called delegates.
So what is a delegate?
Well Microsoft says:

A delegate is a type that represents references to methods with a particular parameter list and return type. When you instantiate a delegate, you can associate its instance with any method with a compatible signature and return type. You can invoke (or call) the method through the delegate instance.

I will not go into it any further than that, but Func<T> & Action<T> are pre-defined delegates, that are also Generic. I will not cover generic methods and types in this discussion other than to say that they can be defined to work on the types that we want.

Ok, well to me that still sounds like gobledy-gook. How would I use one?

Ok, well letā€™s imagine Imagine Ben Franklin GIF we are inside a BPM, in a custom code blockā€¦

//Ignore my lack of null checking please...
//And I have this code here that gets the first letter of a string
string firstLetter = someString.Substring(0, 1);

//And I keep using it and using it and decide I want something cleaner
foreach(string s in someListOfStrings)
{
    DoSomethingWithThis =  s.Substring(0, 1);
}

var myList = new List<string>();
if(someOtherString5000.Substring(0, 1) == "f")
{
    myList.Add(someOtherString);
}

And you wanted to clean it up a bit.

You could do the following:

Func<string, string> GetFirstLetter = (s) =>
{
    if(String.IsNullOrEmpty(s)) return null;
    return s.Substring(0, 1);
};

string firstLetter = GetFirstLetter(someString);

foreach(string s in someListOfStrings)
{
    DoSomethingWithThis =  GetFirstLetter(s);
}

var myList = new List<string>();
if(GetFirstLetter(someOtherString5000) == "f")
{
    myList.Add(someOtherString);
}

Ok, I see how that could be useful. Anything else I need to know?

Yes, a few.

First, Func<T> & Action<T> must be defined before you use them, so they need to be somewhere above any code and in scope. Think of it like a variable, because it really is a variable. It just holds a method, instead of an object or value.

OK, well how do I make one, and what is the difference between the two?

Ok, second question first.

The difference between the two is you will use Func<T> when you need to return values from it, and Action<T> when you do not. You can also use Func<T> and not use the return from it, but you must have a return.

Ok, well what is this <T> bit?

Iā€™m getting to it. (Itā€™s the generic bit, that Iā€™m not really discussing lol)

The way you define a Func<T>:
In short, like this:

Func<[inputType(s)], [returnType]> [MethodName] = ( [inputVariableName] ) =>
{
    //Do work here
    return [returnType];
};
//Like...
Func<string, string> GetFirstLetter = (s) =>
{
    if(String.IsNullOrEmpty(s)) return null;
    return s.Substring(0, 1);
};

The way you define an Action<T>:
In short, like this:

Action<[inputType(s)]> [MethodName] = ( [inputVariableName] ) =>
{
    //Do work here
    //No return
};
//Like...
Action<string> ShowAMessageOrSomethingCool = (s) =>
{
    if(String.IsNullOrEmpty(s)) return;
    InfoMessage.Publish(s);
};

Hey, I caught that, you have ā€œ[inputType(s)]ā€ up there. Huh?
Well yes, you can pass more than one argument if needed, like so:

Func<string, bool, string> GetFirstLetter = (s, ifNotA) =>
{
    if(String.IsNullOrEmpty(s)) return null;

    string temp = s.Substring(0, 1);

    if(ifNotA == true)
    {
        if(temp == "A") return null;
    }

    return temp;
};

And thatā€™s pretty much it.


But wait! What in the world is that ( ) => { }; crazy stuff?

Oh that? That is what is called a Lambda, and that my friend is a topic for another day. For now, just follow directionsā€¦

4 Likes

Btw, short tidbit, what I did there with the

if(String.IsNullOrEmpty(s)) return;

and then continued on is called a Short Circuit.

Itā€™s just a way, via personal preference or style and occasionally (rarely?) performance to skip the rest of the code instead of using an if / else type of construct.

The same thing could be written as:

Func<string, string> GetFirstLetter = (s) =>
{
    if(!String.IsNullOrEmpty(s)) //Notice the ! (Not)
    {
        return s.Substring(0, 1);
    }
    else
    {
        return null;
    }
    //Or several bajillion other ways
};
1 Like

Variables, Variables, Variables
Variables, Variables, Variables
Variables, Variables, Variables

Bill Gates Microsoft GIF Am I old?

What did you think I would do at this moment?

Ahem, I mean, what is a variable?
From: Wikipedia:

In computer programming, a variable is an abstract storage location paired with an associated symbolic name, which contains some known or unknown quantity of data or object referred to as a value ; or in simpler terms, a variable is a named container for a particular set of bits or type of data (like integer, float, string etcā€¦)

Or in even simpler terms:

A variable, for our purposes, is a name we use to represent a value, or an object, or some other abstract thing.


//Structure:
//[VariableType] [VariableName](the actual variable) = [VariableValue];

//This is a variable (a string)
string aString = "Hello";

//These are variables too:

//Boolean (true / false, 1 / 0)
bool bandersonIsCranky = true;

//Int32 (-2,147,483,648 to +2,147,483,647)
int x = 8675309;

//dynamic object (an empty one)
var o = new {};

//An object (DataSet)
DataSet ds = new DataSet("MarkWonsilIsAUnicorn");

etc, etc, etc

1 Like

Rules are up, possibly subject to change.

Ask some questions people, I need something to do between working periods.

image

Thatā€™s not a variable, thatā€™s a constant :laughing: :imp:

1 Like

How do you run, and interpret, a trace?

thatā€™ll keep him busy for a while

2 Likes

When do you use a Data Directive vs a Method Directive?
What is the difference between In-Trans and Post-Trans, Pre, Base and Post?

9 Likes

I think Iā€™m out after my late night stupidity session.

Sort of like eating an elephant. One line (object) at a time.

Yup. Either for the trace OR the elephant.

Iā€™m not going to put every question up there in the top, just the good ones, and I might miss some every once in a while.

Note, all those so far are good, and need an answer, so they are included at the top.

I broke out the top into levels. Doesnā€™t make much difference now, but will in the future.

Hate to kick a dead horse, butā€¦ @Mark_Wonsil might say a WIKI for this would be nice :joy:

BTW I can / will turn on WIKI editing on this post otherwise after a day or two you wonā€™t be able to edit the post any more.

I think you are mistaken, I just edited one of my other posts in the experts corner and itā€™s been there for ages.

Yeah you got LEVEL 4 super powersā€¦ but others donā€™t. I put it back you got enough power to make it happen

Gotcha, ok, do what you gotta do so others can edit then please.

Or do I just click create wiki?

Yup, but maybe wait until you are done setting it all up.