Certificação SCJD – Parte 03

PorFernando Franzini em

Leia os artigos anteriores:


Nesta terceira parte sobre dicas da SCJD, quero abordar a segunda fase da prova. O chamado Essay consiste
em o candidato prestar uma prova escrita de 90 minutos, na qual ele terá
que responder, em inglês, algumas questões relacionadas com o desenvolvimento de
seu projeto. Os objetivos são:

  • Questionar o candidato sobre a coerência do seu entendimento nas
    questões que o levaram a tomar as decisões descritas no documento de
  • Provar a autoria do candidato no código-fonte submetido na primeira
    parte do projeto. Ou seja, comprovar se o candidato que está prestando o
    essay é o mesmo que escreveu o código-fonte do projeto submetido.

Baseado nessa linha de raciocínio, seguem algumas dicas para os candidatos interessados:

  1. Faça um resumo escrito de seu projeto, descrevendo os principais
    pontos arquiteturais
    : nomes dos pacote e das classes, quantidade de
    camadas, nomes e localização das interfaces chaves etc. Ou seja, você
    precisa memorizar as características únicas do seu próprio projeto.
    Estude bem antes de prestar a prova para que você possa descrever tudo
    sobre seu projeto, caso seja questionado.
  2. Uma dica legal é que você descreva as respostas características
    (nome de classes, pacotes, interfaces etc) do seu projeto mesmo que não
    esteja explicitamente questionado.
  3. Faça um resumo das opções arquiteturais consideradas, cada uma com seus
    pontos positivos e negativos, juntamente com o porquê da decisão de um, e
    não do outro. Estude bem esse resumo, uma vez que o
    candidato também poderá ser questionado sobre suas decisões.

  4. Faça um resumo dos padrões de projetos usados e onde ele foram encaixados.

Na época em que prestei essa certificação, acabei fazendo uma série de
estudos e levantei os tópicos mais comuns que podem cair nessa fase da
SCJD. Com isso, eu elaborei o meu resumo, relacionando com as opções que eu
tive que fazer quando fui aprovado. Para fechar a dica, eu estou
disponibilizando aqui o resumo em inglês, para que os candidatos
interessados possam ter um template de ajuda:


01. Wich options did you consider?

2-tier or 3-tier.

02. What are the advantages & disadvantages?

2-tier advantages:

  • the complexity
  • development time

2-tier disadvantages:

  • Tightly coupled – coupling the details of persistence in the gui layer
  • Fat client – information processing is done on the client side
  • Increased network stress – all data is transported to the client side
  • Hard to reuse codes
  • Complicated versions maintenance – application
    logic is executed on the client – machine (maybe thousands) have to be
    updated. This can be very expensive, complicated, prone to error and
    time consuming

3-tier advantages:

  • Loosely coupled – avoid coupling of the details of persistence in the gui layer
  • Centralization and encapsulation of business rules
  • Code reuse – Facilitate the addition of different types client such as a web application
  • Independence between layers
  • Maintainable and extensible
  • Transparency in data access
  • Deploy between different host

3-tier disadvantages:

  • Increased complexity.
  • Risk of over-architecting.

03. Which did you choose? Why?

3-tier because of its advantages.

04. How does it work for your assignment?

  • I created a bussines layer between data and gui that centralized all bussines rules.
  • Bussines layer was defined by suncertify.bussines.RoomService interface.
  • I created two polymorphic implementations of this bussines layer – Local and Remote.
  • Local was implemented by suncertify.local.LocalRooomServiceImp class.
  • Remote was implemented by suncertify.remote.RemoteRoomServiceImp class.

RMI vs Sockets

01. What are the advantages & disadvantages?

Socket advantages:

  • Performace and scalability – less network traffic.
  • Full control over threads.
  • Easier for a junior programer to understand and maintain.
  • Easier to propagate changes to services.

Socket disadvantages:

  • Don’t have protocol – must be writte a custom one.
  • Tedious to implement – Write a lot of code to controls sockets and spawn threads to each client connected.
  • Responsibility to write multithreaded sever.
  • Type-unsafe – Errors can be caught in runtime.

RMI advantages:

  • Transparency – the communication mechanism is completely hidden by technology.
  • Object based semantic – remote objects look and feel just like local object.
  • Protocol – there is no need to worry about designing protocol between client and server.
  • Type safe – all communication is based on interface and errors can be caught in compile time.
  • Multithreaded sever for free.

RMI disadvantages:

  • Less performace and scalability:
  • Proxy object layer betwen client and server.
  • Look up registry.
  • Heartbeat messages.
  • There is no control over threads.
  • Learning curve a little higher (interface,proxy,registries,rmic) than well socket solution.

02. What did you choose? Why?

RMI, because I did not want to spend my time implementing mechanisms for remote communication.

03. Did you create stubs?

Yes, that was mandatory.

04. How did it work for your assignment?

I created an interface called suncertify.remote.RemoteRoomService that extends my bussiness interface and java.rmi.Remote.

Design Patterns

01. Did you use any? Wich? Where?

  • Singleton, Adapter, Transfer Object, Factory and Template Method.
  • suncertify.db.Data implemented Singleton ? Persistence layer.
  • suncertify.remote.RemoteRoomServiceImp implemented Adapter ? Bussines layer.
  • suncertify.bussines.Room implemented Transfer Object ? Bussines layer
  • suncertify.remote.ServiceFactoryImp implemented Factory ? Remote bussines layer
  • suncertify.view.ConnectionWindow implemented Template Method ? View layer.

02. What could
you use but didn’t ? Why ?

  • In my opinion, is an overhead to use the MVC and create all necessary classes in so few GUI operations.
  • The bussines layer encapsulates rules that can be reused in different types client such as a web application.
  • Avoid increase the complexity of the code.

Locking Mechanism

01. Wich approaches did you considered?

Synchronized methods or java.util.concurrent api.

02. What are the advantages & disadvantages?

Synchronized Methods advantages:

  • Easy implemention (for junior programmer).

Synchronized Methods disadvantages:

  • No concurrency because it uses exclusive lock on the object – poor performance.
  • No guarantiees about next granted thread – JVM select.

java.util.concurrent advantages:

  • Read concurrency because it uses many read locks that improve performance (but just one writte lock).
  • java.util.concurrent has better performance than the synchronized methods.
  • Guaranties about next granted thread.

java.util.concurrent advantages:

  • -Complicated implementation (not for junior programmer).

03. What did you choose? Why?

I decided to synchronized methods because:

  • The assignment did not mention any performance requirement.
  • Easy implementation.
  • Easy understanding for junior programmers.
  • Avoid increase the complexity of the code.

04. How did it work for your assignment?

I implemented a class called
suncertify.db.Data that uses the singleton pattern and marked all
persitent methods as synchronized to ensure only one instance and


01. What layout managers you use for the GUI? Why?

BorderLayout, FlowLayout and GridBagLayout. They were the ones I felt that fit better in the construction of graphical user interfaces.

02. How does the JTable get its data, what table model did you use ?

I created my custom TableModel called suncertify.view.RoomTableModel that extends javax.swing.table.AbstractTableModel. I overrode some methods and add one called getRoom (int index).

03. How did you use event handling?

I dont use MVC cause it is an overhead, in my opinion. I implemented simple listeners approach inside each GUI classes.

Exception Handling

01. Wich approaches did you considered?

Return error codes or throw objects exception

02. What are the advantages & disadvantages?

Error codes advantages:

  • Easy and fast implementation.

Error codes disadvantages:

  • Degrade quality: code with many conditional statements contains higher errors probability.
  • Increase development cost: Bug finding, bug fixing, and testing are all increased by unnecessary control flow complexity.
  • Possiblitade ignoring exceptional conditions – error code can be completely ignored.
  • Missing information – tells that something went wrong, but not the reason for the failure.
  • Increases the complexity.

Throw object exceptions advantages:

  • Robust code.
  • Separate the error handling from the application logic.
  • Exceptional conditions can not be ignored because there must always be a catch handler.
  • OOP approach – treated as an object encapsulating all the necessary information.
  • Decreases the complexity.

Throw object exceptions disadvantages:

  • Performance penalty – used in unusual circumstances and inappropriate manner can make the code a little slower.
  • Overuse can increase the code implementation.

03. What did you choose? Why?

To throw object exceptions, because of its advantage.

04. How did it work for your assignment ?

I created an exception for each layer that was used to isolate the occurrences of exceptional conditions.

  • Persistence Layer: suncertify.db.DataBaseException.
  • Bussines Layer: suncertify.bussines.BussinesException.
  • View Layer: suncertify.view.ViewException.

Searching implementation

01. Where and How?

  • The suncertify.db.Data class implemented OR logic, as was mandatory. I used two nested commands ‘for’ and String.startsWith.
  • The AND logic was implemented in bussines layer through the suncertify.local.LocalRoomServiceImp class.
  • To select between the OR or AND logical, was created a class called suncertify.bussines.Criteria used as parameter.

Phrases Template

  • Did I decided to create?
  • Did I decided to implement?
  • Did I decided to separate?
  • Did I decided to use (X) because?
  • Did I implemented a class called suncertify.(X) that?
  • Did I decided to use (X) instead of (Y) because, in my opinion, there was no need to?

Vale lembrar que esse resumo está relacionado com as decisões e
com os requisitos que eu tive que contemplar na minha solução, não sendo uma
“Receita de Bolo”, uma vez que cada prova cobre diferentes requisitos e
situações. Estou à disposição para quaisquer dúvidas. Até a próxima.

Deixe um comentário! 0

0 comentário


O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Comentando como Anônimo

leia mais
Este projeto é mantido e patrocinado pelas empresas: