Teaching .Net–my role as Teacher

Earlier this year, I started practicing some affirmations.   They were along the lines of “There is opportunity everywhere”, and “I do not know myself.”  The intention was that if there’s some way that I could be growing, that the Universe will guide me to it.

There are so many subtle (and possibly not-so-subtle) things that have changed for me since then.  Or, rather, I haven’t changed – I’ve always been me – but I’ve discovered new modes in which I am comfortable.

One of these is regarding my role as a teacher.   There’s a long story arc – it probably starts at helping new wizards to code LPC on a Mud in 1991, stops by at creating training materials for Perl at a startup in 1997, touches on creating Unit Testing and Integration Testing video lessons for a company in 2009.   This latest leg of the story involves:

  • Assisting (briefly) with being a mentor for Code Louisville, and being sad that there was not a .Net curriculum, and attempting to design one;
  • Being considered by a company to be a lead .Net instructor at a bootcamp that’s coming to Louisville. 
  • Having a serious chat with a dude who knows how to teach teachers; getting introduced to Madeline Hunter’s “Mastery Teaching”. To be honest, only got through the first 4 chapters or so, but wow.   (Note: link to the book I COULD have gotten; I got an older and much more bare-bones book).
  • Being asked to help a guy with learning IoT specifically.  I got paid in Qdoba and Starbucks.  Turns out he knew it already, didn’t know that he knew it.  THAT’S ALL?  I giggled and continued eating my burrito, and then we talked about bunches of other stuff.
  • And today, helping a person start to crash-learn .Net.   No, Double-A, I did not Video, so I guess it didn’t happen.

How did it Go?

I had designed a curriculum; given the learner is an experienced programmer, I was hoping that we’d be able to blaze through the material.   However, ‘twas not so.   We blazed, yes; but being a .Net programmer for 15 years, there are so many things I take for granted that we ended up discussing.  For example:

  • Assemblies vs File boundaries vs Namespaces  (did you know ildasm.exe not on disk anymore automatically? when did they change that? A little harder to get a visual on things now)
  • Solutions vs Projects and why oh my?
  • bin vs obj
  • PDB files
  • rearranging the Visual Studio panes and tabs and “Reset Window Layout”
  • Keyboard shortcuts (for somebody used to vi, it’s a learning experience!)
  • GAC references vs project references; when does the public key token come into play?  (and then, also, NuGet)
  • Appropriate .gitignore files, no, you don’t need to save the packages/ directory
  • int vs System.Int vs boxing vs DateTime vs String, and how that plays out with ref & out; when is it a pointer or not?
  • .Net framework versions
  • Garbage Collector internals, as compared to other languages; generational collection; finalization.
  • Assembly version mappings, the new DLL hell.  (We never talked about DLL hell)
  • Stream vs StreamWriter vs TextWriter and the amazingnessballs of System.Io
  • Reflection, typeof(), GetType(), serialization
  • String.Compare(,,true) vs StringComparison.InvariantCultureIgoreCase, and culture, and evolution of the .Net framework.

So in 4 hours, we got a good amount done – enough to get them dangerous – a console app that kept track of a todo list and persisted between runs.   I hope it got him to a spot where he could investigate MVC on his own.  I also pointed him at Pluralsight, and we’re going to follow up via email for the rest of this week.     Btw, Pluralsight is the densest stuff I’ve seen; second runner up is Lynda, then we start talking Microsoft Virtual Academy.  

How did it map to Mastery Teaching?

As a thought experiment to myself, I am attempting the mapping.  How did I do?  How could I improve?

1.  Content, Behavior of Learner, Behavior of Teacher

I think the layering of content worked fairly well.  For example, used int.TryParse() to introduce out parameters, and String.Format() to introduce “params”.   A little slow at times; but we kept improving a program, which gave a nice feedback cycle for success.

Learner and Teacher behaved mostly well.    There was no dancing in chicken-suits.

2. Level of Concern, Feeling Tone, Success.

Already talked about success.  The ongoing concern mapping was to take a known body of information (“how to program in Go and PHP”) and to map the concepts to .Net.    Feeling Tone was ongoing successes, was pretty good, though after about 3.5 hours, definite brain depletion.

3. Interest, Knowledge of Results, Intrinsic/Extrinsic

By keeping the functionality of the program we were working on as a dangling carrot, interest stayed high.  The way we worked it is, I would write some code on my laptop demonstrating something, then he would write similar (sometimes the same) code on his laptop, trying to achieve the same result.  On the way, there were fun little learning things (keyboard shortcuts, debugging, inner exception drilldowns, etc) that kept the learner’s implementation “fresh” rather than a copy – when it worked, they KNEW how they got it to work.     All the motivation was Intrinsic.

4. Review, Anticipatory Set, Objective

I had the curriculum broken out into sections.  For example: “Hello World” followed by “console app in a while loop accepting commands from user”.   I think I could have done a better job bookmarking the sections, and doing the anticipatory set.  I didn’t bother with Review because we were both firing on top cylinders.. or .. maybe I did.  After we did a block, I’d go back to the curriculum and see if we had covered all the topics for that round.     And the end of each block, there was a definite objective – “having a working program that does X, where X is useful in a geek evolution way”.

5. Basic Info / Organization, Simplest form, Modeling.

Each module introduced a very small set of new things.  Some chunks were larger than others, for example:  using(), IDisposable, System.Io.StreamWriter, Xml Serialization, gettype() all went together – I couldn’t think of a meaningful way to make that smaller.   

Because we started from a console app, we were able to hit concepts in small buildable chunks.  For example, int.Parse() => exception => try/catch to deal with exception => int.TryParse => out parameters.   We evolved the code and ran it each time, enjoying the error messages given.

I did NOT want the first .Net code they saw to be a Controller + View + Entity Framework.  (Except they ran ahead and created a project as such already.  Holy crap that’s a lot of firehose)

That’s as far as I’ve really gotten through the Mastery Teaching stuff;  And that’s pages 1-38 of that book.  Pretty crazy, huh?    This is some good Shizzle.

Finishing the rest of the book is still on my list; however, its one of those where you read a chapter – and only a chapter – and then it has to stew in your head for a weekend.  So, it will be a little bit.

In Conclusion

I did not choose to become a full-time instructor.  I’m sad about that… it has to do with schedule and availability-of-free-time and mobility than it does about whether I like it or not.  I love organization of information and teaching somebody who wants to learn.

But, hey, maybe I can do this one-on-one kind of tutoring instead.  

And if there’s demand for it, maybe I’ll make some spending money at it too.   Smile   (Relax, U.S. – using you as a guinea pig to prove out my curriculum.  Thank you.)

Future Tweaks

  • I  think I’d have to budget about 3 hours for .Net basics, 3 hours for MVC/web, and 2 hours for EF?  Oh, another 1 hour for SqlCommand.  This is paired-time.
  • I’m not sure if the loading could/should be “watch pluralsight first then we code together” or “code together then watch pluralsight then write your own” or what.      I think there’s definitely “parrot the instructor but you type it yourself and enjoy it yourself” and then “do the same thing on your own project.” steps that could be played as well.  (At no point will I touch the learner’s keyboard/mouse – everything they do is by their own typing).
  • I think a limit of 1-2 hours per day of active instruction time seems right, to give brain-sink-rearranging time to gel.

Super Excited. Feeling Mighty. 

Anybody else want to be my guinea pig, see if I can fine-tune my .Net tutoring / teaching skills?   I think 1 more test subject before I would start charging.   

Note to self:  him vs they – I kept switching.  I’ve spent 30 minutes or more on this post, so I need to post it and move on.    Kitten just tried to walk across keyboard.  Red heart

Detailed Testing of Very Large Forms

I was given the task of “testing everything” regarding an integration for my client.  

image

This is a screenshot of a document of screenshots; appropriately zoomed out so that no detail is visible.

  • The source system is in yellow; those are portrait screenshots of a multi-page web-form.  
  • The target system is in gray; its several screens of a Windows app.
  • It used to be that gray was loaded from PDF’s, and yellow generated PDF’s.   Human error, lots of time, etc.
  • Now there is an intermediate system, lets call it blue, that is used to load the gray system.   It has a code-generated API document that is 467 pages long, that mostly tells you that X field is stored at Y location in the database that gray displays fields from.

You might think that this could be straight forward, but its not:

  • Some fields in yellow are old, and do not belong in gray
  • Some fields in gray are manual entry, cannot be loaded via blue.
  • Some fields in gray will in the future be loaded by blue, but not yet
  • Some fields in yellow actually go to another system, purple.
  • Furthermore, yellow is customizable.  Not everything is displayed for everybody; some of the fields had never been used before to my knowledge, and might just be old stale stuff.

No problem!  Just have the business persons spec out which fields go where!

  • There’s a business person who knows yellow.
  • There’s another person who knows blue.
  • And another person who knows how blue loads gray, and knows more about gray.
  • Everybody knows about the existence of purple. But, I didn’t find a person who knew purple.  And blue doesn’t talk to purple, and we’re only talking to blue.
  • These people are hard to pin down and have like 15 minutes to spare, tops.
  • Even if I could get them all together, how to document it?
  • The solution would be to find the person who was interested in having yellow go to gray who knew the fields on both sides.  Unfortunately, there was no such person available.  This is all speculative work that someday, in the future, would be good to have. 

So, sensing somebody will have to feel the pain… I volunteered (billable) to Brute Force Test it.   Where do I start?

  • I could get an alphabetical list of all the fields in yellow
  • I mostly knew how yellow was put together – approximately which page had which fields.
  • I knew almost nothing about gray.

My Solutionimage

  • Put on my QA Hat.
  • Turn on everything possible in yellow
  • Create a full application (ever possible field filled out), send it through blue to gray.
    • Take screenshots of every screen so there is no doubt what I put in or what I got.
    • Generate an Excel with the list of all fields from yellow, and the values I filled them out with.
  • Because I don’t know gray, I’ll iterate through it one field at a time.  
    • The other ones, I can much more quickly find things, so less seek time.
    • One page, one field at a time, find what I think is the maimagetch in yellow
      • I did this against the excel spreadsheet that I had generated from yellow.
    • Using pen and paper, cross stuff off from my screenshots of gray.
    • Using Excel, update the field to field to field spreadsheet with success or failure
  • Use Excel Filters to the group the fields into which groups need to be asked to which person.
  • Ask the questions, get answers, in the 15 minute window I could get everybody together during. 
  • Address individual fields with detected problems one at a time, with screenshots of yellow blue and gray as needed.

imageThis has been my life for the last week and a half.  I’m almost through my second pass of fixing fields, thanks to feedback from the person who knows gray.  And we’re a lot smarter about what in yellow doesn’t map with gray.

Mr. Pink was not harmed during this process.  He can definitely say that he wasn’t because he knows when he was and when he wasn’t.  But he cannot definitely say that about anybody else, because he doesn’t definitely know.

Working Two Clients

I find myself in that not-great-but-necessary position where I’m working with two clients at the same time.

The deal is – one project, A, is winding down.  There’s an (unknown, but getting clearer) picture of the amount of testing that needs to happen.   And my other client, with project B, really needed something changed (prior work) before June 4th.   At the time we said yes, it looked like A would finish in the middle of May …

Here I am.  Both clients know that I’m working with them part-time, and that I have the other client whom I’m also doing work for.   Both are excellent business partners and are easy to work with.   No problems!

However, I’m left with having to juggle tasks between the two of them.  How and when do I switch?

My answer is, I use a modified Franklin Covey Planner system.  I thought I could easily find a link to something that explained it, but I couldn’t, so I’ll just lay it out.

image

  • I divide the page into my two clients.
  • I make a list of everything I can think of that needs doing, whether urgent or not.
  • I figure out the A priorities.  These are things that are critical, MUST be done today, or at least very time sensitive things.
  • Then the “B”’s – important stuff, like do-this-week kind of stuff.
  • Everything else is “C”s, or (gasp) D’s, which I might never get to.
  • At this point I deviate from the Franklin system, and I add some other prefixes:
    • W = things I’m waiting on.  
    • Q = things that can happen quickly, like in a pomodoro. 
    • T = things that happen at a certain time.  Ie, i don’t have a choice of when to do them.
  • I then go through and assign priorities.. A1..N, B1..N, etc.
    • In general, if its more risky, i’d give it a higher priority.
    • If it affects more people, I’d give it a higher priority.
    • I’ll put the Q’s before the non-Q’s.   Because crossing more things off my list is better.

Then, here’s the two client bit:

  • I always do A’s cross-client, switching context as I need to.
  • Then I settle down on one client till my next big break, like lunch, perhaps .. work on its stuff.
  • Big break – lunch – or visit the Gym just down the street.
  • Resume with other client.

I don’t try to hide from one client if I have an “A” to go work for the other client.

Another hack I’ve found is, instead of using Pomodoro’s with an alarm, I’m using them with 25-minute playlists (from either Spotify or Amazon Prime).  When the music stops playing, its time to wrap up the current thought and take a micro-break.  I have tried Richard Franklin’s “Music to Code By”, but I seem to be doing more EDM now – stuff like Gold Panda, Tycho, etc.     Thank you Amazon Prime Electronic Betas for Work Playlist.

Thoughts about being a Tutor – 2015

A while ago, I was a mentor for CodeLouisville.    It was fun, but it was also Front-End design – something I needed to learn on the fly to keep up with the coursework that I was mentoring.  I met a lot of folks who were excited about learning.

There was some criticism of the program, though.  One such criticism was, Why aren’t you teaching .Net?  Louisville has a lot of .Net work available.  The answer, for CodeLouisville, was a lack of teaching resources.  They are reliant on “free” resources (as in, LFPL paid TreeHouse and thus it was now free for Louisville residents and workers), and at that point in time TreeHouse did not have any .Net curriculum.  (They have since hired somebody and they are working on it).

This annoyed me, and so I (along with some other folks) tried to design a .Net curriculum.  I think the design was good, but the problem we kept hitting was the lack of consistent free curriculum.   And under the umbrella of CodeLouisville, I couldn’t venture into paid curricula like Pluralsight, for example.

The other thing holding me back was, adjusting to the speed of a class of people.   Some folks go fast, some folks go slow.   How to enable success?

And finally, there is the conversion of time to money.   I used to not have any free time, but thanks to kids getting older, I’m finding myself able to reclaim an evening or two a week.  I have my own projects I’m super-interested in, however, I’m also interested in having spending cash to buy coffee and gadgets with. 

So here’s the pitch:

  • Hire myself out as a private .Net / C# Tutor.
  • I get to help a person 1-on-1 in the direction / goal of their choice.
  • I get spending money.  Cash, Starbucks Gift Cards, or Amazon Gift Cards all work for me.  

How much $ do I charge?

  • For folks with hardship, I don’t know yet.  
    • Definitely won’t be enough to replace my day job Smile
    • Maybe the first time around, its on a pay-as-you-can basis as I get the kinks ironed out of the process? 
      • I want to help people get better, so I’d discount myself for folks in hard spots.
  • In cases of non-hardship, I would not discount myself.  For example:
    • Employers hiring me to train-up their employee
    • Parents hiring me to tutor their high-school kid.    
    • I’m thinking $50/hour for these instances, that feels right.  
      • I reserve the right to change my mind before or after a session;
      • I will not change my rate during a 2-month session.

What’s the curriculum and method of study?

  • Depends on where the student is at, and where they want to get to.
  • I would steer the student towards Pluralsight.  Its got the best content that I know of, as a learning tool.  I would, in fact, discount the cost of pluralsight from my tutoring fee.  But if that’s not how they learn, we can find other ways for them to collect information.
    • There is a TON of content out there, but the quality varies.
  • I would guide the student into picking a personal project that is interesting to them, that is not too hard, yet not completely ridiculously easy.
    • The personal project must involve at least two related sets of data.  We need some parent/child complexity to be real-world complex.
  • We would meet once a week for 1-2 hours, and pair-program (or side-by-side program) our way towards completing that project.

.Net is Huge, what specifically would I cover?

  • I’m an old fogey, so I’d start the student off with a console application.
  • Get them to put data in a database.  Start of with SQL Express.
  • Then either go with a Windows/WPF version, or a WebForms/MVC version, of their app.
  • We can also visit other topics like web services, javascript/jQuery/Ajax, SSRS, stored procedures, optimizing SQL, profiling, EF, etc.
    • I am intentionally wanting to take the student the “hard way” through doing some of the stuff (the way it used to be done) before we switch to the easier way which hides the complexity.  For example, SqlConnection before EntityFramework.
  • If desired, we can visit “advanced” topics like:
    • Unit testing, IoT/Dependency Injection
    • Integration Testing, Automation best practices
    • Scale testing (I’d need to refresh myself on this)
    • Waterfall vs Agile vs Scrum vs …
    • Art of Software Estimation
    • I suspect these are more appropriate if I’m hired by an employer to up-train an employee.

What I cannot do:

  • I am not a UI / CSS / Make it Look Pretty person.    I would not dare teach best practices around that.
    • I am, however, good at detecting UX problems (usability). 
  • I am not a mobile-dev person at this time.
  • I cannot teach an uninterested person.  You have to want to learn, be curious.
  • I cannot guarantee employment if you are un-employed. 
    • However,  if you show me the job description your are interested in, or if you are an employer, tell me what you want your candidate to be like, I can teach towards achieving those skills.

Am I a good instructor?

  • Rider Rodriguez, who ran CodeLouisville, thinks I am.
  • Most of my students during my single stint at CodeLouisville as a mentor think I am.
  • I have a very good intuition / radar: I can detect where people are at in their understanding of something and then guide them to getting new things understood.  
  • I’ll hazard a Yes.
  • If I’m not, I’m open to feedback, and I can learn from feedback.

Does this take away from CodeLouisville?

  • First, CodeLouisville does not currently cover .Net programming.  So, no, I don’t think so.  If a person really wants to learn .Net, and thus spends their time with me instead of them, then who is being served?
  • Also, I’m doing this one-on-one.  If I were teaching a class, then that might be different, but I’m really trying to focus on making one person shine at a time.
  • If CodeLouisville does pick up .Net, I definitely would not want to detract from them getting students and/or compete with them.   I will visit that thought in the future when it becomes reality.

 

What do you think?   Is this feasible?  Do You know somebody who would want to hire me in this manner?   Find me on twitter at @sunjeevgulati if you are interested.  

Currently available for May/June/July 2015.

Fun Things Lately

I don’t know when I’ll have time to do a proper update, so here’s a list-dump of geeky stuff I’ve been up to lately:

  • I started playing Cities: Skylines two days ago.  My brain is processing all kinds of patterns around roadways and pedestrian paths and stuff like that. 
    • imageimage
    • Left was my 6th or so city.. Right is my 8th or so city.  I keep trying to get things “perfect”. 
    • I made a chart of “Noise Polluting” vs “Ground Polluting”, and another chart of “Who wants to be near whom”. 
    • My best idea so far is a big Triangle with Commercial, Industry, and Residential at each corner.
  • My 3D printer broke, and then resurrected itself – there’s a loose power wire going to the extruder.  Its jiggered so that it works for now.
  • I volunteered to make a unique 3D print for a fundraiser basket.  I started off in blender, ended up doing it mostly in OpenJSCAD.  Here are the draft (left) and almost-final-but-slight-oops (right):
  • At work, not much is new.    Still working in an fairly simple MVC app, which deals with gathering user input, filling out PDF’s, and submitting information to various external services.
    • A little bit of PDF parsing and modification that I’d never done before.
    • A little bit of image-detection using some System.Drawing libraries (to detect if what the user uploaded was a valid image)
    • Mostly churning through smaller tasks in preparation for a release.
    • A lot of dealing with configuration migration problems.   Finding a way to export and import configurations between environments so that changes only need to be hand-typed once, and then can be copied from environment to environment. 
    • Next week I get to start investigating 3 services I’ve never talked to before.  Exciting!

House Print 4/N: “Second Beta”

image

I have 3.5 floors printed!  And they go together!  With Stairs!

image image
image image

There are some problems:

image I forgot to cut a section out of the “concrete” that the family room sits on to make room for the stairs from the basement up to the family room.

I also had a hard time getting the steps on the left to fit – I had to resort to my wife’s Dremel to cut some of it down to size.   (Incidentally, a Dremel doesn’t cut it, it selectively melts it via friction)

image I did not make the basement 7ft high like it really is.   Thus, the kitchen is than in reality – and the stairs are the wrong height.

In this same picture, you can also see the problem I have with trying to get the stairs to fit.   
The kitchen wall does not line up with the bedroom wall.

image I ran out of filament with 3 pieces of the bedroom to go.   If I had not made mistakes, I could have gotten the whole thing in a 1kg spool.   (In the pictures above, notice the bedroom has no upper section)

I have ordered a 2kg (5.5 lb) spool of white (“Studio Line White” from JustPLA.com);  With it I’m going to start over.  This time:

  • Correct the basement height
  • Put the stairs in from the start so they get “cut” correctly.  
  • I want to reflect where the ground level is better.

~~~~~~~

For this blog post, I snapped this tag:

https://github.com/sunnywiz/housejscad/tree/Post4

image

When I get time, I plan on making a how-to video – for my own benefit, since a year from now I won’t remember the details:

  • How to create the blueprint
  • How to size the blueprint to create the text overlap
  • How to use the code to generate the STL’s
  • How to use the Join libraries to make the pieces possibly fit each other
  • How to use the Cut libraries to make things printable on my print bed and Plate them
  • How to use the Microsoft / NetFabb Cloud service to fix the model
  • How to use Blender to section the shells off into separate prints
  • How I glued things together (as best as I have found so far)

Pewee, we have a problem (House Print 3/N)

(I live in Pewee Valley, KY, not Houston, TX)

image

This is the 1:48 scale print of the fourth floor.   The source is here:  https://github.com/sunnywiz/housejscad/tree/Post3  and the STL files you are seeing here are bedroom0.stl, bedroom1.stl, and bedroom2.stl.

Problem: The top half doesn’t quite fit the bottom half.   This is because the top half isn’t large enough to hold the shape together – when the roof prints, its warm, and as it cools, it wants to shrink, and so it wants to curve.  The bottom print wants to do the same, but the walls are large enough to prevent this from happening.

Solution: no-roof.  Which, my wife points it, is the way to go:  then you can easily play with the furniture inside.   The side effect of that is, in the current iteration, I won’t be doing top/bottom alignment tabs (similar to the “cross” thing on the left side of the picture). 

Otherwise, the 1:48 scale is working well.  Here is the same bottom half, but with Victorian doll furniture inside it:

image

The checkerboard at the bottom of the picture is also working well as a place to glue things.  Here it is glued to the next piece:

image

Pretty proud of it so far! 

Using OpenJSCAD to print a house (2/N): Small Print!

I advanced the code significantly:

https://github.com/sunnywiz/housejscad/releases/tag/Post2

  • I introduced a “TwoD” class to take the pain out of working in the 2-D character space.
  • I traced out my house’s 4th floor plan to a text file, so I’m dealing with the real thing now rather than test data.
  • I got my 3D printer back up and running – didn’t need any re-calibration after 6 months of no-use.  I had to go read the powerpoint of the presentation I gave a while back to re-remember what to do.
  • The result is this print, which is 1:72 scale, and took about 4 hours (1 failed print included):  

image

Its in two pieces so that:

  • I don’t have to print support structures for the doorways and windows
  • We see things at eye-level, or about 5.5 feet; the model is 8 feet; this makes the model feel overly tall.  With a removable section a little lower, this becomes more “playable”. (I need to move the cut line up though to be at about 5 feet.  Or, move the windows down a bit)

I’ll do a full “How To” video at some point in the future – I’m not quite done yet.  There’s some bleeding edge stuff in the “cuts” branch at the moment:

  • I’ve learned how to do real drag-and-drop libraries, in a separate file, which will work with OpenJSCAD
  • I’m working on a cutting algorithm that will let me cut with tabs.  Its workable now, but needs some fine tuning on gap distances.
  • We’ve (wife and I) decided to do the final print in 1:48 scale – there’s a lot of toy furniture out there available at that scale.  And it will be printed in white.

More to follow at some point.

Using OpenJSCAD to Print a House (1/N)

Since before I got my 3D printer, I’ve wanted to make a scale replica of my house.   I tried doing it with Legos once – it was cost prohibitive.

I came up with a workflow where I drew out the entire house in SweetHome3D, and then exported that, but I ran into manifold problems and stuff like that.

So I did one of the floors in Sketchup.  However, that was a painfully task – and the resulting model was still too big (I want 1:24 or 1:36 scale).  I’d have to slice up the model to print out individual pieces, which means I wanted to cut them in such a way that they joined together with some kind of self-aligning joint.

I was about to try it again, but the sheer amount of detail that I had to go through kept holding me back.  I wanted a formula.

A recent blog post brought my attention to OpenJSCAD. and an Idea formed in my head:

Convert THIS: image
Into THIS: image

I had tried to do something similar in OpenSCAD before, however, because that language doesn’t have procedural elements, I ran into all kinds of problems.   Fresh new start!

So I set about to do it.

As you can see by this screenshot, I succeeded.

The code is here: https://github.com/sunnywiz/housejscad.  It took me about 2 hours.   You can see the commit log, I committed every time I figured even a small piece of the puzzle out.

UPDATE 2/1/2015:  the code as of this blog post is tagged with “Post1”, ie https://github.com/sunnywiz/housejscad/releases/tag/Post1  — the code has since evolved. Another blog post is in the works.  I guess I could “release to main” every time I do a blog post.  Heh.

The Code

  • Provide a translation of map character to 1x1x10 primitive anchored at 0,0,0
  • convert the template into a 2D Array, so that I can look for chunks of repeated stuff.
  • Walk the pattern, looking for chunks.  Rather than get fancy, I made a list of all chunk sizes from 6×6 down to 2×1, and check for each one at a time.
    • There are more efficient ways to do this, but IAGNI.
  • If a chunk is found, generate the primitive for that chunk, scale it up, and add it to the list.  “Consume” the characters which we just generated.
  • When all done, union everything together.

Notes about the Code

  • The resulting file is not manifold, however, NetFabb fixes that pretty easily and reliably.
  • The chunking is necessary if I want to represent steps in an area.    Otherwise, I didn’t need it.
  • You can define any mapping you want .. from a character to a function that returns a CSG.
  • Could probably use this to generate dungeon levels pretty easily.  Or, maybe take a game of NetHack and generate out the level?  Coolness!

Where would it go from here

  • Lay out an actual template of (part of) the house, and fine tune it from there.
    • Probably involve adding “and I want the result to be exactly 150 by 145mm” type scaling.
    • The functions will probably start taking arguments like (dx,dy) => so that the function can draw something intelligent for an area that is dx by dy in size.
    • I just noticed, the output is mirrored due to axes being different between R,C and Y,X
  • Preferably, I’d like to create a object / class that does this work, rather than the current style of coding.  IAGNI at the moment.  Then, maybe running in node, I could take the different floors and convert then into objects, and then do further manipulation on them..
    • Like slice them into top and bottom pieces.  Windows and doors print a lot better upside down – no support material necessary.
    • Would also need to slice them into horizontal pieces.  My build platform is limited to 6” square.
  • I live in a very 90-degree-angle house.   Thus, this kind of solution would work for me.  Sorry if you live in a circular, or slightly angled, house, this solution is not for you.    Buy me a house, and I’ll build you a solutiion. 😛
    • Seriously thinking about this.  I’d probably have a template of “points”, and then a language of “Draw a wall from A to D to E”;  and then “place a door on wall from A to D at the intersection of F”  or something like that.

A fun night of short and sweet coding.  I had to look up a lot of javascript primitives, mostly around arrays of arrays, and checking for undefined.

Some day I’ll get that “doll” house printed.  Then I can make scale sizes of all my furniture from Lego’s!  Fun fun.

Code for doing Explosions

Playing FortressCraft Evolved, I played with explosives.  I was not particularly happy with how the explosives were handled – and I was on vacation, and I had no internet access, so my creativity got into my brain and I tried writing code that would handle explosions better.

I shoved the code here:  https://github.com/sunnywiz/explosion2d

Here’s the basics of what I did:

  • I did this in 2D instead of 3D because easier to Console.WriteLine()
  • I created a TwoDSpace<T> so I could store an arbitrarily large number of T’s in a 2-D plane
  • I created a function which mapped out, given a center 0,0, what the distances were to each X,Y. 
    • I kept distances as squares, so I didn’t have to do square roots.
    • I did it with an initial max-radius, but the final version in my head would jit-figure out what it needs and save the resulting calculations in a static – it only needs to calculate it once.  Bigger explosion might need to calculate some more.  
  • That function can then call to a lambda, giving it:
    • the X,Y of the point that is being visited by the explosion
    • an array of parent points for the explosion and the ratios by which to weight them
  • The caller then says, “circle visit an explosion starting from here”, and keeps track of the force per X,Y that is being experienced.  The caller is responsible for all the code that says “Ores are hard, but dirt is soft”, for example, or “Diamond cannot be damaged by the explosion”
  • I think its pretty fast. O(r^2), which given its a 2D explosion in 2D, is expected. 

Fun Fun stuff.   I miss the days of mud coding.   You just don’t need to do explosions like these in real-world paid programming.