January 13, 2011

I'm moving over to my new site: http://www.williambruschi.net. I leave this site up though. See you over there!

August 27, 2010

at Friday, August 27, 2010 Labels: Posted by Billy 0 comments

In the world of software development, managers have deployed many
strategies over the years to guide complex software projects. As the
result of the numerous headaches and failures, different methodologies
have arisen that try to handle the malleable process of developing
software. The so-called waterfall approach, a mirror image of
traditional management of most non-software projects, first
entails producing an unequivocal specification that theoretically
leads to a simple implementation process.

Nevertheless, this waterfall approach failed time and time again for
many software projects. In comes the Agile software development
approach. It encourages rapid and incremental development, continuous
communication with the customers, adaptation and self organizing

Scrum is a method of agile software development, and Agile Project Management with Scrum by Ken Schwaber gives
real life stories of teams that used scrum successfully and
unsuccessfully. The stories are short and illustrative of common
pitfalls and misunderstandings that teams encounter when first using
Scrum. For example, one such story told of a Scrum Master running the
daily scrum meeting, asking each developer what he/she has
accomplished and assigning them their next task. This is a major
violation of Scrum; Scrum teams are self managed. The Scrum Master
facilitates the use of Scrum for the project, but scrum teams decide
who works on what and the best way to get the job done correctly.

This book was a quick read and great introduction to Scrum. No
software development process is perfect, however, and neither will any
new methodologies that may appear in the future be either. In my ideal
world of software projects, developers should never need to attend
meetings, interruptions will never spring up, and they will work
unbothered in "the flow" all day long. However, people need to
exchange information and software development is a team game. The
Scrum process seems to be a great way to boost productivity, satisfy
managers and stakeholders, and increase workplace moral.

August 15, 2010

at Sunday, August 15, 2010 Posted by Billy 0 comments

Unhappy with the lack of a sophisticated way to auto-generate public properties from private variables in Visual Studio, I turned to EMacs to implement my own version. The code at the end of this post is for VB.NET. It takes a buffer like this:


and changes it to this:

Private strLastName As String
Private strFirstName As String
Private intAmount As Integer
Private dblPrice As Double

Public Property LastName() As String
    Return strLastName
  End Get
  Set(ByVal value As String)
    strLastName = value
  End Set
End Property

Public Property FirstName() As String
    Return strFirstName
  End Get
  Set(ByVal value As String)
    strFirstName = value
  End Set
End Property

Public Property Amount() As Integer
    Return intAmount
  End Get
  Set(ByVal value As Integer)
    intAmount = value
  End Set
End Property

Public Property Price() As Double
    Return dblPrice
  End Get
  Set(ByVal value As Double)
    dblPrice = value
  End Set
End Property

You can easily configure the variable types it detects by modifying the alist *vb-types*. At work I have adjusted the template to expand into code complying with my company's coding guidelines. To use, visit a new buffer, type in the names of your private variables prefixed with a type designator, then type M-x props.

(defconst *vb-types*
  '(("str" . "String")
    ("dbl" . "Double")
    ("int" . "Integer")))

(defun var-name (var)
  (unless (< (length var) 4)
    (substring var 3)))

(defun var-type (var)
  (unless (< (length var) 4)
    (let ((type (substring var 0 3)))
      (cdr (assoc type *vb-types*)))))

(defun insert-private-vars (var)
  (let ((type (var-type var)))
    (when type
      (insert "Private " var " As " type)

(defun insert-properties (var)
  (let ((type (var-type var))
 (name (var-name var)))
    (when (and name type)
      (insert "
Public Property " name "() As " type "
    Return " var "
  End Get
  Set(ByVal value As " type ")
    " var " = value
  End Set
End Property

(defun props ()
  (let ((vars (split-string (buffer-string))))
    (mapc #'insert-private-vars vars)
    (newline) (newline)
    (mapc #'insert-properties vars)))

July 5, 2010

The Pragmatic Programmer: From Journeyman to Master was a quick and relatively fun read. The book covers many broad topics of everyday programming, such as project management, documentation, testing and automation. While reading I noticed that I already follow many of the principles outlined in the book, but reading it on paper helped encourage me to continue to do so.

Most of material new to me concerned project management and customer relationships. Two such items include having a project glossary and choosing appropriate ways to pleasantly surprise customers.

All programmers should know the book's material and practice it everyday. In my opinion, college's should require more reading of this type to help prepare students for the real world. Overall, it is a great book for professional programmers.

June 4, 2010

at Friday, June 04, 2010 Labels: , Posted by Billy 0 comments

Many people unfamiliar with Common Lisp believe it's a purely
functional language, but this is untrue. While you can shape your
Common Lisp programs in a functional way, Common Lisp also support
Object Oriented Programming via CLOS, the Common Lisp Object
System. It is truly a multi-paradigm language.

This books teaches all the aspects of CLOS, and although written
several years ago, the knowledge still applies today. After learning
about Object Oriented programming using languages like C++ and Java,
learning about CLOS really opened my eyes to what this style of
programming should feel like. All the other languages now seem to
constrained compared to the power and flexibility of CLOS.

In CLOS, classes only have member variables, called slots, and support
multiple inheritance. They do not define methods. Instead, methods are
defined for Generic Functions which specialize on the classes. While
most OO languages use single dispatch, meaning methods specialize on
only one class, CLOS uses multiple dispatch. It also supports
specializing on distinct object instances. In addition to primary
methods, CLOS has before, after and around methods. You can even
dictate the order in which CLOS calls all of the applicable methods.

I truly enjoyed this book as it expanding my understanding of object
oriented techniques. I hope the mainstream language designers can take
the time to read this and incorporate more of CLOS into today's
popular, but limited, object oriented systems.

May 31, 2010

;;; SICP Section 3.1

;;; 3.1
(defun make-accumulator (n)
  (lambda (x)
    (incf n x)))

;;; 3.2
(defun make-monitored (f)
  (let ((count 0))
    (lambda (x)
      (cond ((eq x 'how-many-calls?) count)
     ((eq x 'reset-count) (setf count 0))
     (t (incf count)
        (funcall f x))))))

;;; 3.3 and 3.4 - updated for 3.7
(defun make-account (balance password)
  (let ((consecutive-attempts 0))
    (labels ((withdraw (amount)
        (if (>= balance amount)
     (setf balance (- balance amount))
     "Insufficient funds"))
      (deposit (amount)
        (setf balance (+ balance amount)))
      (dispatch (pass m)
   ;; Incorrect password?
   ((not (eq pass password))
    (lambda (x)
      (if (<= 7 (incf consecutive-attempts))
   "Calling cops"
   "Incorrect password")))
   ;; Withdrawing?
   ((eq m 'withdraw)
    (setf consecutive-attempts 0)
   ;; Depositing?
   ((eq m 'deposit)
    (setf consecutive-attempts 0)
   ;; Creating joint account?
   ((eq m 'joint)
    (lambda (new-pass)
      (lambda (pass m)
        (if (eq pass new-pass)
     (funcall #'dispatch password m)
     (funcall #'dispatch nil m)))))
   (t (error "Unknown request -- MAKE-ACCOUNT")))))

(defun withdraw (acc pwd amt)
  (funcall (funcall acc pwd 'withdraw) amt))

(defun deposit (acc pwd amt)
  (funcall (funcall acc pwd 'deposit) amt))

;;; 3.5
(defun random-in-range (low high)
  (let ((range (- high low)))
    (+ low (random range))))

(defun monte-carlo (trials experiment)
  (labels ((iter (trials-remaining trials-passed)
      (cond ((= trials-remaining 0)
      (float (/ trials-passed trials)))
     ((funcall experiment)
      (iter (- trials-remaining 1) (+ trials-passed 1)))
      (iter (- trials-remaining 1) trials-passed)))))
    (iter trials 0)))

(defun in-circle-p ()
  (let ((x (random-in-range 0 1.0))
 (y (random-in-range 0 1.0)))
    (<= (+ (expt (- x 0.5) 2)
    (expt (- y 0.5) 2))
 (expt 0.5 2))))

(defun estimate-integral (p x1 x2 y1 y2 trials)
  (let ((area-of-rect (* (- x2 x1)
    (- y2 y1)))
 (frac-inside (monte-carlo trials p)))
    (* frac-inside area-of-rect)))

;;; 3.6
(let ((st (make-random-state)))
  (defun rnd (sym)
    (cond ((eq sym 'generate)
    (lambda (x)
      (random x st)))
   ((eq sym 'reset)
    (lambda (x)
      (setf st x)))
   (t "Unknown symbol"))))

;;; 3.7
(defun make-joint (acc pass new-pass)
  (funcall (funcall acc pass 'joint) new-pass))

;;; 3.8
(let ((num 1))
  (defun f (n)
    (setf num (* num n))))

May 25, 2010

at Tuesday, May 25, 2010 Labels: Posted by Billy 1 comments

I recently updated to Ubuntu Lucid and immediately noticed UI performance degradation after using it for a short while. The sluggish performance affected window switching and scrolling in Firefox/Chrome/Evince etc. Nothing on my system indicated a memory leak or chewed-up processor.

I searched Ubuntu's bug tracking system and came across this post, which indicated the using the latest kernel version fix the problem. After following the steps here to update my kernel, my system runs as fast as ever. Hopefully other users experience my situation will stumble across this post and find it helpful.