Joe Conley Tagged mongodb Random thoughts on technology, books, golf, and everything else that interests me (Triz)Swagging out at the Philly Codefest <p>This past weekend I teamed up with some buddies from <a href=""></a> (<a href="">Angel</a>, <a href="">Jon</a>, and <a href="">Dylan</a>) to participate in my first hackathon, <a href="">Philly Codefest</a>. We spent the weekend bringing Angel’s dream to life: a platform called TrizSwagger to analyze and track the use of “swag” (i.e. T-shirts, office supplies, and other marketing mathoms). We leveraged social media and geolocation to give companies real-time visibility to their marketing campaigns. Feel free to check out the app <a href="">here</a>.</p> <table class="image"> <caption align="bottom">Angel demoing's apiDoc service</caption> <tr><td><img src="/assets/angel.jpg" alt="Angel promoting" /></td></tr> </table> <p> <br /></p> <h2 id="lessons-learned">Lessons Learned</h2> <p>Good programming is always concerned with simplicity and efficiency, whether it’s using efficient data structures and algorithms, conciseness in your codebase, or even naming variables properly. Building an app in 24 hours, however, throws the need for simplicity and efficiency into sharp relief. Here are a few takeways from my experience.</p> <h3 id="coast-to-coast-json">Coast-to-Coast JSON</h3> <p>I’ve always been a big fan of <a href="">Domain-driven Design</a>. Writing POJOs in Java and case classes in Scala can provide a clear crystallization of the main actors of your application. However, models may not always be necessary, especially if your app is backed by a service/database which gives you JSON (TrizSwagger is backed in <a href="">MongoDB</a> and served by <a href="">Flask</a>). The extra layer of complexity in marshalling/unmarshalling between JSON and your model can hinder performance and readability of your code, especially if you’re using heavy ORM frameworks like Hibernate. During a hackathon, if you’re rapidly making changes to the model you’ll surely get slowed down. For a more thorough treatment of JSON Coast-to-Coast, check out <a href="">the Mandubian Blog</a></p> <h3 id="knockoutjs-mapping-plugin">Knockout.js Mapping plugin</h3> <p>In order to implement coast-to-coast design effectively, it’s important to have a front-end framework that manages JSON well. One such framework I’m fond of is Knockout.js, more specifically their <a href="">mapping plugin</a>. This plugin automatically maps a JSON message into a Javascript observable object. You can then code the front-end directly against object properties without having to pre-define a viewmodel. You can also customize how objects are mapped by either modifying or enhancing the created object. This strategy proved quite helpful during the hackathon as any changes to our back-end API literally only had to be changed in one place (the front-end).</p> <p>One caveat is the creation of a new object using this plugin. Since the plugin requires a JSON object to build out the observable, I wrote a basic method in Play to take an expected JSON object and “empty” it, setting default values that would be used in the new object form.</p> <script src=""></script> <h3 id="understanding-your-tools">Understanding your tools</h3> <p>TrizSwagger integrates with both Twitter and Facebook. Understanding and setting up those integrations, however, occupied a lot of our time. We also ran into issues with a server on OpenShift, slowing us down further. Ultimately I think simpler is better, and every choice in technology needs to be well thought-out and well-suited to its use case.</p> <h2 id="conclusion">Conclusion</h2> <p>Overall it was an awesome experience. Even though we didn’t win (or place, or show for that matter), we learned a lot and we still took the time to mentor other teams who were using the <a href=""> API</a>. Great job Team TrizSwagger!</p> <table class="image"> <caption align="bottom">Jon, Dylan, and Joe doing some last-minute coding</caption> <tr><td><img src="/assets/triz.jpg" alt="Jon, Dylan, and Joe doing some last-minute coding" /></td></tr> </table> Tue, 25 Feb 2014 00:00:00 +0000