Wednesday, October 30, 2013

Not Following Conventions and Other Bad Ideas






Conventions are there to help you. Sometimes you need to override them most of the time you don't.

Future Troops: Here are some things I've done (and seen) that you shouldn't do if you can avoid them. Feel free to add your own in the comments


  • If you don't follow class, table, and list naming conventions, you're gonna have a bad time.
  • If you change your namespace mid project, you're gonna have a bad time.
  • If you don't learn to read error messages, you're gonna have a bad time.
  • If you use Bootstrap 3 and Layoutit.com together, you're gonna have a bad time.(Use Bootstrap 2.x and you'll be fine)
  • If you don't practice on your own, you're gonna have a bad time.

Tuesday, October 29, 2013

Get & Set!

Success! 

Data comes out! Data goes in! 

The magic words were:

                 db.Clients.Add(Nclient);
       db.SaveChanges();

It's a little more complicated than that but that's what I was missing. While banging my head against the problem I got the following points.

How to Access Information Returned In A Query String
string a = Request.QueryString["SomeField"];
String Interpolation
 string a = string.Format("{0} {1}!","Hello", "World");
You can also use variables:
string h = "Hello";
string w = "World";
string a = string.Format("{} {}!", h, w);

Catching Errors: (Sometimes) Keeping Errors from Crashing Your Program
try{
CoDeThAtCrAsHesYoUrApP();

catch{
}
The code in try runs and is a success or fails, if it fails then we can handle the error in the catch section. I need more work on this but it's an interesting starting point.

 Week 2 Day 2






 

Monday, October 28, 2013

UPDATE progress SET Week1='done',status='banging head against SQL' WHERE coder='Alex'

Week 1 is behind me at this point and so far things are a success. I can now do in 45 minutes in visual studio with Bootstrap what would have taken me an entire day hand coding PHP.

Today we reviewed what we covered last week. Then moved onto SQL statements. Getting data to populate and narrow with SQL calls from C# is fine(SELECT statements and WHERE clauses). I'm making lists( and therefore dropdown menus) dynamically. It looks good, works well.



There's one small problem.

I can't get the thing to update or insert from C#. The code runs properly in SQL Management Studio, just not when wrapped up in C# goodness. No one in my research is doing it the way I'm trying to. It seems there's a reason.

We'll get some tools later this week that will make life easier.

Thursday, October 24, 2013

Thanks

To future troops: Get help from the people who came before you. They're nice people. They will help.

I wanted post a quick thanks to some people in earlier troops that have helped me out with both lessons and encouragement while I'm still in the sucking phase.

Josh 
Ben




Wednesday, October 23, 2013

Schrodinger's Cat: Wanted Dead AND Alive



If you don't know about Schrodinger's Cat you should.

The state of being alive can be represented by a boolean value. True or False. Alive or Not.

Structs have to have a value. So if I create a new bool, Cat.IsAlive, it takes the default bool value of false. Here's the code to prove it.

public class Cat{
     public bool IsAlive{set; get;}
}

Cat SchrodingersCat = new Cat();

Console.WriteLine(SchrodingersCat.IsAlive);

output:
False

Poor kitty...

If you take the default bool he's always dead. The problem is before you open the box, you don't know whether the cat is alive or dead. Sometimes he survives...and is angry. You still want to use a bool. Just make it nullable.

public class Cat{
     public bool? IsAlive{set; get;}
}

Cat SchrodingersCat = new Cat();

Console.WriteLine(SchrodingersCat.IsAlive);

output:

That's better. It looks empty. And it is...kind of. It's null. After you run Box.Open()the value will change to a good'ol true or false.

Before the box is opened the cat isn't alive or dead, it's just null.


Day 2 Recap -- Getting # on OOP

Today we covered some higher level concepts of Object Oriented Programming. The main ones we focused on were inheritance, encapsulation, data hiding and polymorphism.

The most complex of the three was polymorphism. Essentially you put an instance of a child variable inside of a parent variable's instance. Only the parts of the child variable that the parent can understand (like overridden methods, or properties) are accessible.

In the process we saw some C# and got examples of class creation, child class creation, instantiating a class, writing(simple) functions and calling them.

Creating a class
public class Coder{
     public string Name{set;get;}
     public string Language{set; get;}
     public int Age{set; get;}
}
Creating a new instance of a Class
Coder p = new Coder();
using dot notation to set variables for the new instance
p.name="Alex";
p.Language="C#";
p.Age=27;


public void Code(){
Console.WriteLine("Someone is coding");
}
calling the function
Code();

Tuesday, October 22, 2013

Day 1 Recap

It's the morning of Day 2.

Day 1 went pretty well. We've got 5 great guys in our troop. We're smaller than most of the other troops. This is going to be good for cohesion, but will limit the scope of what we can get done on our group project.

We got bogged down by the release Visual Studio 2013, (it went live yesterday morning and they removed 2012). There are some upgrades like built in support for bootstrap and some aesthetic upgrades.

The group project will go well. We used screen shots and paint to put together mock-ups of new features to add to an existing project base. Today we'll get feedback and make sure we're headed in the correct direction.

David is also going to hit us with the basics of OOP in C# today. The intensity is about to get turned up quite a bit, let the games begin!