Grails Flashcards

(21 cards)

1
Q

Java Bean

A

A Java Bean is a class that fulfills three criteria:

  1. All properties are private (accessed via getters/setters)
  2. Constructor is public and has no arguments
  3. Implements Serializable (so returned objects can be serialized)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

AST Browser

A

A Groovy tools that allows you to see how your code is compiled (parsing, conversion, semantic analysis, etc)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

JD-GUI

A

A tool that allows you to decompile your .class files to see what was added to them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Closure

A
  • A function written inside another function that has access to the outer function’s scope
  • A closure “saves” the outer functions local variables, and if the closure is returned when the outer function is run, it will still have access to the outer function’s scope even though the outer function has finished running
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Abstract Class

A

A class high up in the hierarchy that defines variables and methods that should be present in each of its children, but leaves it up to the children to define those methods.

It guarantees that the children have a common set of variables and methods that are necessary for those children to communicate with one another (think of it as a common language among the children)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Interface

A

Similar to Abstract Class, but:

  1. Two objects to not need to be related to implement the same interface - common language among non-related classes
  2. Interfaces are “stricter” - they can only have final variables and abstract methods. Abstract classes can have abstract methods, concrete methods
  3. A class can implement multiple interfaces, whereas it can only extend from one class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

void

A

Indicates that method does not return anything

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Autoboxing and unboxing

A

Converting a primitive value into an object of the corresponding wrapper class is called autoboxing. It occurs if you assign an primitive to variable of the wrapper class, or if you pass a primitive into a function that expects the wrapper class.

Unboxing converts it back to the primitive type, and occurs in the reverse scenarios described above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Access Modifiers

A
Private - only same class  can access
Default  - only classes in the  same package can access
Protected - Default + subclasses in a different package
Public - Everybody get's a variable! You get a variable..
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Overloading

A

Having the same method but with different, but using different parameters to create different method signatures. When calling the method, the method with the same number and data type positioning in the arguments will be called

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Null-safe Deference

A

In Java, person.organization.name will throw a null pointer exception if organization is not defined. However, person?.organization?.name will return null and your code can procede

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Elvis Operator

A

String name = person.name ? person.name : default name is equivalent to String name = person.name ?: default name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Singleton

A

A class that instantiates only one object at a time. You cannot create two instances of a Singleton to get two different resulting children

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Views are located…

A

In grails-app/views

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Angular Controllers are located…

A

In grails-app/assets/javascripts/angular-modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

URL Mapping is located…

A

In grails-app/conf/UrlMappings.groovy. However, by default, grails will look at the path of the URL and look for a controller class that matches that path, with “Controller” appended to the end of it

17
Q

Services are located…

A

In grails-app/services. To create a service, just create a class in the grails-app/services directory, and append “Service” to the end of the class name.

18
Q

Transactional Services

A

By default, all Services in Grails are considered transactional, meaning they have the necessary support to communicate with the database

19
Q

Domain Classes

A

Domain Classes are located in the grails-app/domain directory. The class name maps to a database table name, and the field names map to database field names. For both, camelcase is converted to snakecase. Any field that is not scoped (public, private, protected, etc.) is assumed to be a database field name

20
Q

How to inject a Spring Bean

A

Spring Beans are public, so all you need to do is call the bean by name and set it to a variable scoped to your class. For example, if you wanted to inject the user service spring bean into your class, write the following:

private Object userService
void setUserService(Object userService) {
this.userService = userService
}
21
Q

@Transactional tag

A

A Spring annotation that defines whether the class method (and the methods it calls) are part of a transaction. It also allows you to define aspects of the transaction - read only, timeout, rollback rules, etc