Skip to content

Instantly share code, notes, and snippets.

@martinusso
Created November 16, 2011 19:00
Show Gist options
  • Save martinusso/1370983 to your computer and use it in GitHub Desktop.
Save martinusso/1370983 to your computer and use it in GitHub Desktop.
Refactoring #1
// Improving the reading and understanding of your code
{ Before }
Utils = class
public
class property MessageUtils: TMessageUtils read FMessageUtils;
TMessageUtils = class
public
class procedure ShowWarning(const message: string);
class procedure ShowError(const message: string);
// using
Utils.MessageUtils.ShowWarning('Hello World!'); // ugly
{ After }
Utils = class
public
class property ShowMessage: TMessageUtils read FShowMessage;
TMessageUtils = class
public
class procedure Warning(const message: string);
class procedure Error(const message: string);
// using
Utils.ShowMessage.Warning('Hello World!'); // cool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment