Singleton design pattern vs. static classes

During an internal .NET 101 training at Microsoft one of my students asked a very interesting question: why would we choose to use a Singleton design pattern instead of simply using a "global" static class?
 
After some thinking and investigation, here are my conclusions of the benefits for sticking with Singletons:
  • Singletons are objects and it might be more intuitive to deal with them for state manipulation rather than through the use of static fields in static classes.
  • In the same line, you can’t pass a static class as parameter, while no such limitation exists for the Singleton object.
  • Static classes cannot implement interfaces. The class that defines the Singleton can.
  • The global static class can be loaded too early, consuming valuable application resources, while the Singleton supports lazy allocation where an instance is created only as needed.
  • Static classes do not benefit from default serialization mechanisms.

BR,
– AFurtado

Posted in Software Engineering | 22 Comments

Brazil wins Imagine Cup for the 5th time! / Brazil vence a Imagine Cup pela quinta vez!

versão em Português mais abaixo

For the fifth consecutive year, Brazil wins a category at the Imagine Cup world finals (the biggest student technology competition in the world). This time, team LEVV It, from Pernambuco, got the first place with in the Game Development invitational with the game Choice.

As one of the judges of the XNA Challenge Brazil 2009, I was able to play the game and was impressed by its game design: arcade action is well dosed with strategic insights, and the result is lots of fun!

Brazil also got fantastic results in other categories, such as first place in Design, first place in Interoperability and third place in Software Design (main category), among others. Click here to check all the results. Other relevant news: Romania got the big prize (first place in Software Design) and Imagine Cup 2010 will be held in Poland (cool).

Being a “retired” contestant starting with Imagine Cup Japan 2005, I’m really glad to know that Brazil’s results at Imagine Cup are not one-off, but very consistent across the years. Congratulations to the Brazilian group at Egypt!

BR,
– AFurtado

————————————————————————————————————

Pelo quinto ano consecutivo, o Brazil vence uma final de Imagine Cup, a Copa do Mundo da Computação. Dessa vez, o time LEVV It, de Pernambuco, conseguiu o primeiro lugar na categoria de Desenvolvimento de Jogos com o jogo Choice.

Sendo um juiz do XNA Challenge Brazil 2009, eu pude jogar o jogo e fiquei impressionado com o seu game design: ação estilo arcade se combina muito bem com estratégia, resultando em muita diversão.

O Brasil também conseguiu resultados fantásticos em outras categorias, como os primeiros lugares em Design e Interoperability, além de terceiro em Projeto de Software (categoria principal), e outros. Clique aqui para ver todos os resultados. Outras notícias relevantes: a Romênia ficou com o grande prêmio (primeiro lugar em Projeto de Software) e a Imagine Cup 2010 será na Polônia.

Como um competidor “aposentado” da Imagine Cup, começando pelo Japão em 2005, estou realmente feliz em ver que os resultados do Brasil na Imagine Cup não são por acaso, mas sim muito consistentes ao longo dos anos. Parabéns, comitiva brasileira no Egito!

[]s
– AFurtado

Posted in Imagine Cup | Leave a comment

Twitter reminder

Did you know that:

  • You can format (underline, bold, italic, etc) a word in MS Word without having to select it? Just have the cursor there, then CTRL+B/I/U
  • To return to the location of the last edit in Word, you just need to press SHIFT+F5? In Visual Studio, it’s CTRL – (control + dash).
  • You can download arcade game resources (art, sounds, etc.) at http://themushroomkingdom.net?
  • http://www.wordle.net/create enables you to create your own tag clouds?
  • MS will donate to a hunger-relief organization for every download of IE8 from the site www.browserforthebetter.com?

Those are a sample of tips (plus personal thoughts, opinions and news) I’m sharing on twitter: www.twitter.com/awfurtado. See you there.

BR,
– AFurtado

Posted in Computers and Internet | 16 Comments

Finding bugs through exploratory testing in WolframAlpha

[This post is part of a series. To see the previous, click here. To understand the context, click here]

The Bing search decision engine got lots of attention these days, as being able to double Microsoft’s market share in the search business even weeks after its original release. Personally, I finally got excited by a Microsoft product in such a domain.

Other release that had some attention in the search area was WolframAlpha. As you might know, while you can use Bing or Google to do some simple computations such as measurements conversions and calculator operations, WolframAlpha is a “computational engine” by default (i.e., it computes your input towards a result rather than searching for web pages).

WolframAlpha is cool, giving interesting data as results that Bing and Google do not provide (yet?). Try “Seattle to Recife” there and you will understand what I’m talking about. For example, it can show nice mortgage graphs based on your input (loan amount, interest per year, loan period, etc.). Check it out:

As any other Software Development Engineer in Test, I tried running a couple of “unexpected” queries to check out the application behavior. What about a negative value for the total number of years for my loan period? There you go:

Effective interest rate is now screwed. Graphs and tables in such a scenario are not good either: data get collapsed to the center of the graph, or $Fail!

 

Since one of the coolest features in WolframAlpha is to combine multiple computations (such as “Weather in Seattle when Obama was born”), let’s go a step beyond and assign the square root of -1 as the total number of years for my loan period:

The loan period is now the imaginary number (“i”)! Isn’t it awesome? Only your imagination can tell now when you’ll be done with your mortgage! :) The computation of graphs and other stuff now takes a while and fail as a timeout. Export to PDF feature is also broken. Yay, we found another bug!

Fortunately those are minor errors which won’t avoid me from keeping using WolframAlpha. In fact, I’d love to see Bing moving (actually extending) into such a direction, i.e., computational engines. And what about enabling people to add their own computational logic, formulas and conversions to the engine? I mean, creating a computational engine leveraged by the power of Web 2.0? For example, extending Wolfram or Bing towards a universal slang translator?

PS: Using imaginary numbers to explore other interesting WolframAlpha scenarios is left as an exercise to the reader. :)

BR,
– AFurtado

The statements or testimonies I offer in this post represent my own personal views.
I am speaking for myself and not on behalf of my employer, Microsoft Corporation.

Posted in User Experience | 1 Comment

DSLs: the bad and the ugly

The panel “DSLs: The Good, the Bad and the Ugly” that happened at the OOPSLA 2008 conference discussed the advantages, disadvantages and challenges from the industry and academia on the use of domain-specific languages (DSLs).

While the advantages brought by the panelists were somewhat expected (more productivity, more abstraction, etc.), the disadvantages and challenges were quite interesting and not that obvious. Here you can find a compilation of them:

  • Composition (integration) among multiple DSLs (this was mentioned several times).
  • Interoperability with mainstream languages.
  • Key challenge: understanding the domain and defining its scope. Designing a DSL requires strong customer-driven effort. DSLs targeted at too broad domains are ineffective.
  • Common error: DSLs based on solution domain (code), instead of the problem domain, therefore becoming low level languages.
  • Lack of domain analysis tools and processes.
  • Lack of tool support in general. Knowledge in DSL engineering was not transferred to tools yet. The engineering knowledge is out there, many times ad hoc, but it still had not come together.
  • Tools are immature for iterative development and use of DSLs.
  • A new language implies at reluctant customers. Although they are generally able to understand the return of investment after the using the language for a while, lowering the entry barrier is still a challenge.
  • Users cannot benefit from a DSL if it has poor documentation or they are not properly trained.
  • Planning and assessing the return on investment (cost-benefit analysis) is hard to perform (some panelists argued that a DSL with a generator pays off if used more than once).
  • Lack of systematic approach to replicate processes related to DSLs design and implementation.
  • Manually edition of generated code should be avoided. [IMHO, extensibility through other means such as partial classes, inheritance, dependency injection, etc. are still welcome]
  • Programming concepts (conditional branches, loops, etc.) might be expected by the DSL users but may not make sense to the domain.
  • Backward compatibility: it is hard to evolve the language when model (specs) created with it are already in place.
  • Internal DSLs have a couple of additional challenges: (1) users may move out from the DSL abstractions to the host language and (2) compilers for internal DSLs have to process host language code.

BR,
– AFurtado

Posted in Software Engineering | 22 Comments

[old] Microsoft FrontPage Server Extensions

Problem when deploying a ASP.NET app from Visual Studio: Unable to create the Web site ‘XYZ’.  The Web server does not appear to have FrontPage Server Extensions installed.

Solution: http://www.rtr.com/fpse/

BR,
– AFurtado

Posted in Computers and Internet | 12 Comments

VSX 2010

VSX (Visual Studio Extensibility) 2010 news follow below. The WPF-empowered extensibility is inspiring…

Are you building new tools to simplify your life or change the way people work?  Check out the opportunities to create innovative extensions for Visual Studio 2010.

Examples of cool things you can do:

· Overlay rich metadata on top of the editor to bring new information to your fingertips

· Develop new project templates to accelerate your work (examples: New Project Dialog)

· Create innovative user interface elements using the WPF Shell

· Upload your extension to the Visual Studio Gallery (http://visualstudiogallery.com) to find it in the Extension Manager

            Other things you should know:

· With v2 of the Visual Studio Gallery that went live on 5/14, you can use the Extension Manager to find products from the ecosystem from within Visual Studio

                *(with Beta1, the Extension Manager will only surface extensions posted to the Gallery in the VSIX file format; Beta2 will include the MSI format)

· We just released the new SDK along with the new Shell redistributables, look for them at the dev center: http://msdn.com/vsx

· If you’re developing extensions for VS 2010, you’ll want to stay tuned to the dev center for more information

Fun things to help you get started – these can be found in the Extension Manager (Tools>Extension Manager): search for Editor Extensions


DemoDashboard Sample:

The DemoDashboard sample is a WPF “dashboard” designed for folks presenting demos in VS2010 to get real-time audience feedback via Twitter. Use this sample to give presentations, build your own widgets, etc.  The wiki on the CodePlex site will give you all the info you need to get started. You can share the feedback you get with your followers on Twitter.

get it:  Tools>Extension Manager

or from the Gallery: here

source: http://demodashboard.codeplex.com

RegEx Editor Sample

This sample was built to ease the your pain when working with regular expressions.  It shows re-hosting of the editor in a window and provides a nice starting point for similar projects.

get it:  Tools>Extension Manager

or from the Gallery: here

source: http://editorsamples.codeplex.com

Custom Intellisense Sample

This sample provides a custom WPF-based UI for Intellisense — with databinding and other cool features.  You might want to use it as-is, you might want to personalize it, you might want to build new features for it –  the choice is yours.

get it: Tools>Extension Manager

or from the Gallery: here

source: http://editorsamples.codeplex.com

Image Insertion Sample

This sample is all about visualizing resources inline, it provides some nice transparency effects when you’re dragging an image from the solution explorer, and will automatically resize text to fit the image.

get it: Tools>Extension Manager

or from the Gallery: here

source: http://editorsamples.codeplex.com

FAQ:

                What is the Extension Manager and how do I find it?

The Extension Manager in Visual Studio enables developers to discover Visual Studio Extensions from within the product itself. It consumes data directly from the Visual Studio Gallery, giving developers direct access to partner and community products that extend and enhance Visual Studio.  If you have a free or free trial version of your product hosted on the Visual Studio Gallery, a developer will be able to download and install that product directly from within the IDE.  (In Beta1, the in-product experience will show only extensions uploaded as a VSIX.  In Beta 2 we will expand the in-product experience to also include extensions uploaded as MSI and reference links to other download sites.)

The Extension Manager enables a developer to install, upgrade, uninstall, enable, and disable extensions, making it easier to manage a portfolio of extensions. 

To find the Extension Manager:  Tools>Extension Manager.

                So this means the Visual Studio Gallery can now host downloads?

Yes, we’re excited to announce that the Visual Studio Gallery can now host your downloads.  Keep in mind that at this time the gallery does not include a commerce framework so we recommend creating a free or free trial version of your product that can be hosted on the Visual Studio Gallery.  Of course we still support reference links for users who prefer to host their own downloads.

                What else is new @ the Visual Studio Gallery?

Thanks to some great work by the MSDN team we’ve moved the Visual Studio Gallery to be part of MSDN.  Some of the benefits:

· The new navigation model supports all types of Visual Studio Extensions and has sections for Tools, Controls, and Templates

· The integration with MSDN now gives users a chance to take advantage of a shared profile across all MSDN properties.  Contributing to the gallery can enhance your MSDN reputation giving high quality contributors the recognition they deserve.

· Visual Studio Gallery contributions offer an optional discussion board to separate your reviews and give contributors an opportunity to post updates, respond to feedback, & discuss bugs.

· All entries include a usage chart to give contributors a sense of which of their products are getting the most traffic on the Visual Studio Gallery.

                What’s the deal with the VSIX file format I’ve heard about?

Both the new Visual Studio Gallery and the Extension Manager work with .VSIX files, which is a new deployment model for extensions, similar to a renamed .ZIP file.  This transition provides Visual Studio users a new low-overhead, reliable way to deploy Visual Studio Extensions. There’s tooling available to help you with this, and you can find instructions and other helpful tips at the Visual Studio Extensibility Dev Center:  http://msdn.com/vsx.

                Questions?

                Email catherine.crim@microsoft.com

BR,
– AFurtado

Posted in Computers and Internet | 19 Comments