Saturday, March 5, 2016

Teaching programming related skills to my kids

As mentioned in a different post, I'm not a teacher but I do enjoy teaching my kids things.  Often this is computer related stuff.  Since my son is learning Java at school, I will use that as the initial basis for some teaching opportunities.  He still hasn't learned a number of key items yet but he will hopefully be ready for this by the end of the year. My idea for teaching is not the standard read a book and write some tiny bit of code to learn basic syntax/idea. Instead, I am going to write some relatively small (probably < 2000 lines of code) programs which are highly commented.  The comments will consist of application specific comments but more importantly will include "talk points" about why I did something or how I could do it different/better.  We can then walk through the program itself together and discuss how/why it works.

Items which we may be able to weave into the conversations include:
  • Analyzing options; trade-offs between viable solutions to problems and parts of problems.  
  • Architecture/design/implementation choices.  
  • Evaluation criteria for various choices
    • readability / maintainability
    • ease of expressing a solution
    • performance 
    • cost
I will also try to convey various good/best practices and various things that should be avoided. I am hopeful that he will take the opportunity to try experimenting with the examples as well. 

Even it it doesn't pan out to my fullest desire, I hope that one or both of my kids might learn something useful and enjoy some "geek time" with me.

The initial program I thought of is a Sudoku puzzle solver. A number of us in the family like to work the puzzles at times (some of us more than others).

Here is a link to my initial stab at the well commented Sudoku solver program.
https://drive.google.com/file/d/0B0GbWl6CZQ6lQlZ4S0NHNWpVWVk/view?usp=sharing
This link is to a zip file on my Google Drive containing a Eclipse 4.5.1 project.  You can extract it and import it into an Eclipse workspace. There is a README with some hopefully helpful setup info if needed.

[2016/3/15] Below is a stack based solution with some changes for clarity (in many cases compared to the prior recursive version) and has heavy use of JDK 8 functionality including use of "default" in interface definitions and more stream/lambda examples. I'm sure some of my lambda related code could still be cleaned up - probably with use of method references in some places.
https://drive.google.com/file/d/0B0GbWl6CZQ6lZzh4TVl4a3dUOUU/view?usp=sharing

For this particular program, I think some of the conversations might include:
  • mutable versus immutable data
  • data structure selection
  • object orientation design
  • serial versus concurrent/parallel processing
  • Java 8 "functional programming" features
  • solution strategies
    • brute force
    • backtracking
  • recursion versus stack based implementation 
From a longer term perspective, I might try to create or discuss implementations in other languages/technologies. This might provide me an opportunity to learn some new things at the same time or brush up on some rusty skills. Some initial thoughts on this include: C, C++, Scala/Akka,Erlang, Scheme/Lisp/Clojure, JavaScipt/CoffeeScript/TypeScript.

**
[2016/05/29] As a side note, simply replacing regular streams with parallel streams had a substantial negative impact on the performance.  This was on on a 4 core i5 based system running at 1.70 GHz with Windows 7 x64. Maybe an improvement could be made with some effort but it will take a bit more work than just adding "parallel" in a few places.
**
I'm starting to think about what type of programs might be fun to work on next.  Maybe a web application could be interesting but I think the focus would be more on the supporting technology (i.e. container and frameworks).  Maybe we will make that decision together.

[2016/04/03] Somethings to note, code reviews are a good thing - would have caught a number of my own documentation mistakes in this code which I need to fix.  A code review involves one or more other developers who read the code while looking for errors in logic, code documentation or deviations from some coding standards.  Finding the logic/documentation errors is the best code review usage and has a better chance of working if the developers have some artifact the the logic was created from which can be referenced - probably a design document, use case or diagram of some sort.  Deviation from coding standards is better identified with other software which can be integrated into appropriate places in the chain of software development events.  One of those events might be checking the files/changes into a source control system - something that is important but I am not discussing here.  Creating unit tests are another possible way to catch logic errors if the tests are created based upon the desired true outcome (requirement) versus the actual code/logic which was implemented.  Do some research into Test Driven Development (TDD) for more info in this area.  From a pragmatic standpoint, taking a break from a long coding session and coming back to it after a couple hours to carefully review it again can go a long way to catching your own mistakes (of all types) before others find them.

 Deuteronomy 32:2New International Version (NIV)
Let my teaching fall like rain
    and my words descend like dew,
like showers on new grass,
    like abundant rain on tender plants.

Thanks for reading!
Scott

Monday, February 1, 2016

Gerbil "Escape from Alcatraz"

We are theorizing two things about the gerbils.
  1. They think they are people and should not be penned in.
  2. They watched "Escape from Alcatraz" late night a few times and were inspired.
 Anyways, the plain cardboard we had rigged to the top of their play pen was not working out any longer.  Both gerbils had learned the art of getting to the top of the cardboard - fortunately never at the same time.  One seems to have a quick method and the other was more methodical.  In either case, they were mere inches from having free roam of the house and all the delicious wood furniture.  We were fortunate to notice in time to recapture them.  They seem a little fearful of jumping down from their high position which helped us.  They did not go back without a "fight" though - they tried to go hide in an area in the corner which was hard to get to but in the end we got them.

Since this was not really how I wanted to spend my evenings, I decided to make a better "guard" for the top of the pen.  I had some thin luan plywood (5/32" ?) and some chunks of 1x2 lumber laying around the garage along with a box of 1 5/8" drywall screws.  That along with my table saw, miter saw, drill press and cordless drill and piece of sand paper and I had all I needed to better secure our talented and very gymnastic gerbils.

The basic idea was to:
  • Cut the luan into strips roughly 4.5" x 60" on the table saw
  • cut each luan strip into about 13" lengths (based it on the panels in the pen and made nearly the same length). 
  • sand the edges of the luan a bit since it tends to splinter a lot
  • Cut the 1x2 lumber into 2" length blocks.
  • Pre-drill the 2" blocks through the small edge since they are prone to splitting with the drywall screws. I drilled 2 holes in each but only really needed 1 on the second inner piece. 
  • Locate the first block on the edge of a luan rectangle and drill through original hole and the luan.  That allowed locating where to screw from the top.  Repeat that basic process for both blocks and the remaining screws.  I left about 1/8" gap between them for the fence. And just to note, I probably could have done things differently/faster (pre-drill and  locate hole from top of luan in one step but I didn't think about it until I had already done most of the blocks).
Below is a complete panel.

Here is my daughter placing a panel back on the fench.
 

And this is what the whole thing looks like afterwards.  The only real change I might make is rounding the corners of the panels.  I'll try and make time for that soon.


The gerbils tried it out tonight and so far were not able to effectively use their existing tricks.  I think it will make them try harder.  I'll start planning for the next tactic to keep them contained and safe.

Below is a video of what we were trying to prevent.


Enjoy!


[2016/02/02] aka, the day after.  Ok, so even though the overhang is pretty big - more than 3.5 inches, I found "Thumper" wandering around on top of the new wood panels when I went to check email.  I thought I had them.  Joke is on me. Now I need to find "the next level".  I'm going to have to setup a webcam or something to figure out how they are doing this now.

Thursday, January 21, 2016

FIM management agent w/extension - Disabling AD user accounts

Finally got around to implementing a new FIM management agent (MA) with a custom extension that disables active directory (AD) user accounts.

This has been sitting on my whiteboard list of todo items for some time.  It didn't turn out too difficult but I had to make some changes to another MA which was conflicting with an attribute flow from what I can tell.  That along with some new custom code and MA did the trick.

There was some original (written by a MS consultant) code/setup for disabling users that exist in the FIM management agent (for the portal).  The basic idea that was partially implemented - a custom field in the FIM MA and portal which drives updating the Windows user account control flags (reference) through the Active Directory MA & extension.

The custom field in the portal is updatable. A change to the field ends up in the FIM connector space and propagates to the metaverse (MV).  The MV value flows to the Active Directory (AD) MA which has a custom extension which translates the flag to the appropriate user account control flag value and manages OU changes to the account.  When the custom field indicates to disable a user then logical-or the user account control with 0x2.  When the user is re-enabled then logical-and the user account control flag with a negated 0x2.

We only keep certain users in the FIM MA and portal for performance reasons so the original design wasn't 100% useful and was never fully implemented. It did provide the basic framework for my final solution though.

So what I ended creating is a database feed (new table/views) going to the new MA which has a C# extension.  The database is populated from a utility I created which the local security team has access to.  The new DB feed replaces the custom field in the FIM MA but still updates the same metaverse (MV) data which feeds into the AD MA. So the largest change was removing the existing FIM MA support and replacing it with the new MA.  The remaining changes were more cleanup in nature with some changes needed to simply get things working which had not been fully implemented initially.

At some point, a more general tool will be created to populate the DB table feed and decentralized security teams will have access to it.