rohinsood / csa

MIT License
0 stars 0 forks source link

2015 FRQ --> PBL | Final Review #4

Open rohinsood opened 7 months ago

rohinsood commented 7 months ago

FRQ 1 (1D & 2D Arraylists) | Link

@JdbcTypeCode(SqlTypes.JSON) @Column(columnDefinition = "jsonb") private Map<String,Map<String, Object>> stats = new HashMap<>();

Manipulating the array

repository.addRoleToPerson(person.getEmail(), "ROLE_STUDENT");


# FRQ 2 (Classes) | [Link](https://rohinsood.github.io/csa/2024/02/25/2015-FRQ-2_IPYNB_2_.html)
- This FRQ revolved around using features of a class to most efficiently write code. Some topics include accessing static methods within the same class, iteration, and other methods.
- The provided Java code defines a class named `PersonRole` that appears to serve as a blueprint for creating objects representing roles in a system. The class encapsulates attributes such as an automatically generated ID, a unique name for the role, and various constructors for instantiation. The use of the `@Entity` annotation indicates that instances of this class can be persisted in a database. Moreover, the `init()` method showcases the concept of class methods creating instances, where three predefined roles (`ROLE_STUDENT`, `ROLE_TEACHER`, and `ROLE_ADMIN`) are initialized and stored in an array. This implementation reflects the object-oriented programming paradigm, treating the class `PersonRole` as a template or blueprint for creating individual role objects. This connection between class definitions and object instantiation aligns with the fundamental concept of classes as blueprints for objects, a concept commonly tested in Free Response Questions (FRQs) that assess understanding of object-oriented principles in programming courses.

```java
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class PersonRole {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(unique=true)
    private String name;

    public PersonRole(String name) {
        this.name = name;
    }

    public static PersonRole[] init() {
        PersonRole student = new PersonRole("ROLE_STUDENT");
        PersonRole teacher = new PersonRole("ROLE_TEACHER");
        PersonRole admin = new PersonRole("ROLE_ADMIN");
        PersonRole[] initArray = {student, teacher, admin};
        return initArray;
    }
}

FRQ 3 (Arrays) Link

FRQ 4 (Interfaces) | Link

import org.springframework.data.jpa.repository.JpaRepository;

public interface PersonRoleJpaRepository extends JpaRepository<PersonRole, Long> { PersonRole findByName(String name); }



# FRQ Reflection
- **FRQ 1:**
  - Simple implementation, not challenging.
  - Emphasized using for-loops to iterate, update, or sum array values.
  - Noted syntax familiarity, but highlighted the need to remember array instantiation.

- **FRQ 2:**
  - Slightly harder than the first FRQ but manageable.
  - Utilized a for-loop to iterate over a provided string.
  - Recognized the importance of sequential order in checking correctness, specifically for position and character existence.

- **FRQ 3:**
  - Deemed the most challenging FRQ due to the implementation.
  - Used a for-loop to iterate over and delete array elements, considered unconventional.
  - Overcame issues by copying indices into an ArrayList and iterated over that to delete elements.
  - Acknowledged that a while loop and checking for the existence of the next element could have provided a cleaner solution.

- **FRQ 4:**
  - Considered the easiest FRQ.
  - Task involved creating an interface and demonstrating usage.
  - Used the @Override annotation to define methods for classes implementing the interface.
STG-7 commented 7 months ago

FRQ 1 (Arrays & ArrayLists)

FRQ - 0.95/0.9

FRQ 2 (Classes)

FRQ - 1/0.9

Association - 1/0.9

FRQ 3 (Arrays)

FRQ - 0.95/0.9

FRQ 4 (Interfaces)

FRQ - 1/0.9

Association - 1/0.9