Wednesday, July 03, 2019

Is OOP compatible with Functional Programming?


Actually, OOP (Object Oriented Programming) was born out of Functional Programming and as such is still considered an advanced application of it.
Watch this 1986 MIT Computer Science class about the SICP book (Structured Interpretation of Computer Programs) and see how it covers OOP in Lisp, one of the oldest Functional Programming Languages out there:
OOP is basically illustrated as nothing other than smart data that knows its own operations automatically through polymorphism.
Example:
Complex numbers can have one of two representations:
  • Rectangular
  • Polar
Each representation has its own algorithms for basic algebraic operations:
  • Add
  • Subtract
  • Multiply
  • Divide
To avoid manually selecting the right algorithm function for each data representation, one may rely on typed data in Lisp so that the data representing complex numbers will know its own operations based on whether its internal representation type is rectangular or polar, and be able to dispatch the right function automatically via polymorphism.

Sunday, June 30, 2019

Puts Debuggerer (debugger-less debugging FTW) v0.8.1

Puts Debuggerer (debugger-less debugging FTW) Version 0.8.1 has been released.

Summary:
Yes, many of us avoid debuggers like the plague and clamp on to our puts statements like an umbrella in a stormy day. Why not make it official and have puts debugging become its own perfectly legitimate thing?!!
Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW!
For background, please read this blog post by Aaron Patterson:
https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html
Ruby gem may be found over here:
https://rubygems.org/gems/puts_debuggerer

Thursday, February 14, 2019

Tic Tac Toe Sharp

Though I have many years of experience in Java and Ruby, I just got my first experience in building a C# project the other day, a small Tic Tac Toe game. It is a command-line program coded with the new Visual Studio Community for Mac.

The code has been posted over here: https://github.com/AndyObtiva/TicTacToeSharp



Pattern Applied: Model-View-Presenter.

TicTacToe is the game Model based on IGame interface, which houses all the logic for making moves, checking for win or draw, and maintaining the board status after every move.

TicTacToeUI is the Presenter of the game model, sending game output to the View and acting as a controller to process input from the user.

MyConsole based on IConsole interface and leveraging C#'s Console is the View, which renders output to the screen and receives input from the user

Noteworthy Details:

  • Starting development in C# with the mentality of Java development worked out quite well
  • Looking for Functional Programming features such as Lambda Expressions from Java 8 and block iterators from Ruby got me discovering LINQ pretty quickly
  • Dynamic typing was available too, which I toyed with initially given my attachment to it from Ruby, and then later reverted to static typing given I discovered the types I needed
  • Attribute getters and setters are on par with Ruby's and probably better than Java's non-existent support for attributes (without using some meta-programming annotations)
  • Operator overloading/indexers are on par with Ruby's and better than Java's lack of support for operator overloading
  • Interface based polymorphism of methods felt cumbersome compared to Java as I had to cast a class object into its interface to invoke interface methods
  • Package management was as good as Java's
  • xUnit testing was as good as Java's and Ruby's
  • Utility methods seemed to support me completely and be on par with utility methods in Ruby and perhaps slightly better than Java's (felt that way though could be just equal)
  • While Visual Studio Community for Mac includes some built-in refactoring features, such as class rename, it is definitely inferior to Eclipse, IntelliJ Idea, and IntelliJ RubyMine. It seems ReSharper, a tool offered by IntelliJ's company JetBrains to enhance Visual Studio is a must. I didn't get to toy with it, but I would imagine I'd do so on future C# projects.
Overall, I felt well supported by C#'s versatility and not lacking any programming features from Java and Ruby.

That has not been my experience with other languages that compare to Java or Ruby. For example, Rust, which I've looked into recently, has a very steep learning curve (albeit quite fun) to writing code that auto-manages its own memory without a garbage collector (Rust's highest selling point and greatest innovation). Also, Perl in its later incarnation seemed to be a clone of Perl-inspired Ruby, providing most of Ruby's features, but with alternative syntax, making me wonder why switch at all. Yet again, that means I get to have the option of consulting for Perl projects if need be (though no sane Rubyist would :P ). The same goes for C# after doing more learning in it. 

I probably did not exploit every C# feature in the course of writing this mini-project.

Comments are welcome, especially that I could be way off in this article due to being new to C#, and would like to be corrected if so.

Cheers and happy coding!

Saturday, January 12, 2019

What is Software Value?

In software engineering, we are often asked to deliver value. Yet, what exactly is software value?

The following questions and answers might help explain it:

What truly constitutes value?

Serving the customer true business needs as opposed to only responding to customer requests, thus providing true customer satisfaction in the long term.

Isn't value subjective?

Value can be subjective, thus requiring a lot of business analysis and usability research to figure out the best software to build. For example, in usability engineering, user testing involves observing users and discerning what serves their needs independently of what they say.

Isn't value the sole concern of the business?

Employees serve the business, and so business concerns become their own too, but each plays a specific role towards attaining software value. For example, in baseball one may think that winning is the sole concern of the team's head coach/general manager, and yet every player must keep that concern in mind while playing their specific role; pitcher, batter, or catcher.

Isn't value a vague term?

All terms are vague if you don't share context with others. Nonetheless, keeping value delivery in mind focuses us on doing what's right to truly serve the customer. Otherwise, we risk getting lost in copying the competition or offering people what they say without addressing their real concerns.

Isn't delivering value as obvious as doing what the manager asks you to do?

It could be if you're a junior software developer unable to discern value yet. As you grow and progress in the field though, you start bringing your own perspective regarding what value is and better discerning what serves the customer and business.

How about value being as obvious as making people feel good?

Feeling good is not the same as customer satisfaction. For example, if a user is getting work done with a piece of software, what serves their needs is doing work correctly and fast, which might not necessarily feel good as it's hard work. As such, you wouldn't target good feelings or else you risk falling into the trap of offering irrelevant features. For example, imagine online spreadsheet software that offers music playback as a feature because it feels good to listen to music while working. Obviously, this is useless for work software not concerning music and might even distract from a good job. Instead, target offering the best business and customer value by figuring out how to best serve business needs (e.g. cloud storage of spreadsheets instead of requiring upload/download on every use).

Always stay open-minded about the perspectives of your colleagues to come up with the best value. I like to share just enough of my opinion, while listening to other developers as well as other team players like usability designers, software architects, and quality assurance folks.

In summary, deliver software value, keep the business and customer in mind, and learn to focus on customer needs not wants.


Saturday, November 25, 2017

puts_debuggerer 0.8.0 is out!

puts_debuggerer, the library for improved Ruby puts debugging, now has better support for Rails.

In a Rails environment, puts_debuggerer now automatically outputs to Rails logs at the debug level. This is facilitated using the new "printer" support, which is a configurable option that comes with smart defaults.

The "printer" option value can be a global method symbol or lambda expression to use in printing to the user. Examples of global methods are :puts and :print. An example of a lambda expression is lambda {|output| Rails.logger.info(output)}
It defaults to :puts , but if Rails is detected, it defaults to: lambda {|output| Rails.logger.debug(output)}
Example:
# File Name: /Users/User/example.rb
PutsDebuggerer.printer = lambda {|output| Rails.logger.error(output)}
str = "Hello"
pd str
Prints out in the Rails app log as error lines:
[PD] /Users/User/example.rb:5
   > pd str
  => Hello

Learn more about puts_debuggerer over here: https://github.com/AndyObtiva/puts_debuggerer

Monday, October 23, 2017

Sunday, August 06, 2017

Ultra Light Wizard v0.1.4 Wizard Step Breadcrumb

Ultra Light Wizard just got an update (v0.1.4). It now ships with a wizard step breadcrumb like the one in this screenshot:



Its semantic markup and CSS is easily stylable and customizable, especially to developers well-versed in HTML5 and CSS3.

Enjoy!