Survey about Code Smells

This survey aims to raise some information about Code smells in the developers' life. For this, we prepared some questions about this subject. It is important that you respond objectively and honestly to the questions below.

The language used in some examples codes of the questions was Java. But, most likely, the developers of others languages (C#, VB, etc...) will not have problems undestanding the code or to answering the questions, because the codes are quite simple.

    General questions

    This is a required question
    This is a required question
    This is a required question

    4) Given the following code

    public class Classe { enum Enum { A, B, C } public static void main (String... args) { Enum value = Enum.A; switch (value) { default : System.out.println("Default"); break; case A: System.out.println("A"); } } }
    This is a required question

    5) Given the following code

    public class Classe { public void method() { System.out.println("Classe"); } public static void main (String... args) { Classe classe = new ClasseFilha(); classe.method(); } } class ClasseFilha extends Classe { public void method() { System.out.println("ClasseFilha"); } }
    This is a required question

    6) Given the following code

    public class Classe { public static void main (String... args) { System.out.println("Hello" + " " + args[0] + ". " + "Bem vindo ao teste " + args[1] + "."); } }
    This is a required question
    This is a required question

    7) When you were looking to a commit that another member of your team did, you see the following method that he created:

    PS 1: The number on the left side is the line of the code, and the pieces between ** (double asterisks) are pieces of code that were hidden because they are unnecessary to the question PS 2: The code bellow compiles and runs successfully 35: public String getDocument() { 36: Document doc = new Document("documento.pdf"); 37: 38: ** Piece of the code that check if the user has permission to see the file** 55: 56: ** Piece of the code that check if the file has already been generated.** 64: 65: ** Piece of the code that make some configurations in the file ** 78: 79: ** Piece of the code that generates the file ** 133: 134: return doc; 135: }
    This is a required question

    8) Analyse the code below that was create by a developer and posteriorly another developer did some modifications in some pieces given it in the actual format.

    PS 1: The same rules of ** (double asteriks) of the previous questions. PS 2: The code compiles and runs successfully class Printer { public Printer getInstance() { return new Printer(); } public void ConfigureDocument(Document doc) { ** Code responsible for doing some complex configurations to the document ** } /** * Print the document in a page with the format A4 */ public void ShowDocumentInAWindow(boolean showFullVersion) { ** Code responsible to open a modal and shows the document ** } }
    This is a required question
    This is a required question

    9) The following variables were declare in the system

    List<Product> products = new ArrayList<Product>(); Set<String> namesSet = new HashSet<String>(); int count; string keyString;
    This is a required question
    This is a required question

    10) Given the method below:

    Obs1: The same rule about the ** (double asteriks) public void GenerateDocument () { ** Write the general data of the document ** if (user.equals('aluno')) { ** Write the general data of the student ** } ** Write some data about the university ** if (user.equals('aluno')) { ** Write the general data of the student ** } ** Write the specific data of the document ** if (user.equals('aluno')) { ** Write the general data of the student ** } }
    This is a required question

    11) Given that exists a class that is used for all the system, in other words, there are too many other methods in the system that instanciate this class or use its statics method.

    This is a required question

    Questions without code

    This is a required question
    This is a required question
    This is a required question