Toby-Leeder / CSABlog

MIT License
0 stars 0 forks source link

Final Review Issue #4

Open Toby-Leeder opened 6 months ago

Toby-Leeder commented 6 months ago

FRQ 1

FRQ 1 had us working with 2D arrays, which could be useful for multiple aspects of our project. Though we haven't gotten to this part yet, we will be able to use 2D arrays to store various datatypes when implementing the stapplet functions of our project. Checking for duplicate data could also be useful in these stapplet functions when adding large groups of data at once.

@Data  // Annotations to simplify writing code (ie constructors, setters)
@NoArgsConstructor
@AllArgsConstructor
@Entity // Annotation to simplify creating an entity, which is a lightweight persistence domain object. Typically, an entity represents a table in a relational database, and each entity instance corresponds to a row in that table.
public class QrCode {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ElementCollection
    private List<LinkFreq> linkFreqs = new ArrayList<>();

    public void addLink(LinkFreq linkFreq ){
        linkFreqs.add(linkFreq);
        return;
    }
}

This code is also a form of 2d array in which nested lists are used. For example, the linkFreqs is an association between a link and a frequency and there is a list of linkfreq objects within each qr code object.

FRQ 2

The FRQ had a branching logic chain, in which one answer led to false and another led to a second if statement. I also utilized this concept when accepting the QR code on the frontend and choosing where to redirect someone. For example, the following code

    function getLink(){
        return fetchId().then(obj => {
            var num = Math.random()
            var intervals = [];
            for (var i = 0; i < obj.linkFreqs.length; i ++){
                if (i == 0){
                    intervals.push(obj.linkFreqs[i].frequency)
                }
                else {
                    console.log(intervals)
                    intervals.push(intervals[i - 1] + obj.linkFreqs[i-1].frequency)
                }
            }
            for (i in intervals){
                console.log(num);
                console.log(intervals[i])
                if (num < intervals[i]){
                    link = obj.linkFreqs[i].link;
                    return link
                }
            }
        })
    }

searches through multiple intervals to check if the value is within the given interval and redirect to the correct link.

Another focus of this FRQ was creating a POJO object, like the QR code object I created here. Though in this case spring actually creates all of the necessary constructors, getters and setters through the annotations.

@Data  // Annotations to simplify writing code (ie constructors, setters)
@NoArgsConstructor
@AllArgsConstructor
@Entity // Annotation to simplify creating an entity, which is a lightweight persistence domain object. Typically, an entity represents a table in a relational database, and each entity instance corresponds to a row in that table.
public class QrCode {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ElementCollection
    private List<LinkFreq> linkFreqs = new ArrayList<>();

    public void addLink(LinkFreq linkFreq ){
        linkFreqs.add(linkFreq);
        return;
    }
}

FRQ 3

This FRQ actually reminded me of what we learned about when learning how to save images into base64, where if the image is primarily a single color you can save that color as a variable and then just record how many pixels have that color in the row. I could see this being useful in our project again for the stapplet functions, where if we are storing large groups of data which primarily contain 1 or 2 of a single datatype, it could be more efficient to store the data by storing the value and number of numbers rather than storing each number individually.

This is similar to the example I could use for FRQ 1 as well, but another example of similar concept is my response object for my qrcode creation api call.

@Data
public class QrCodeRequest {
    private List<String> links;
    private List<Double> frequencies;
}

This object includes two lists which match to the lists passed through to the function when the API is called.

FRQ 4

FRQ 4 had us working with interfaces, this was actually a concept I never really understood before now, but looking through my project I've found instances of using interfaces throughout the project. For example, the following code

    @GetMapping("/{id}")
    @Transactional
    public ResponseEntity<QrCode> getQrCode(@PathVariable long id) {
        Optional<QrCode> optional = repository.findById(id);
        if (optional.isPresent()) {  // Good ID
            QrCode qrCode = optional.get();  // value from findByID
            Hibernate.initialize(qrCode.getLinkFreqs());
            return new ResponseEntity<>(qrCode, HttpStatus.OK);  // OK HTTP response: status code, headers, and body
        }
        // Bad ID
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);       
    }

includes the "findById" method of the repository class. This method is originally defined within the CrudRepository interface which allows us to customize this method based on differing repository classes.

anawandh commented 6 months ago

Crossover Reviews - Aditya Nawandhar

2015 FRQ Scores

Note: We demonstrated running code in notebooks to verify functionality

FRQ # Comments Score
1 Code runs as expected and FRQ type correctly identified 0.9/0.9
2 Code runs as expected, type is Methods and Control Structures 0.9/0.9
3 Code runs as expected and FRQ type correctly identified 0.9/0.9
4 Code runs as expected, FRQ type correctly identified, and additional code for clarity in output 0.9/0.9
Overall Combined score for 1.1 scale FRQs 3.6/3.6

They all work and I liked the reflections and learning part of the FRQ blogs that showed the unique problems you have such as the syntax confusion you had between a java array and a python one. They help prove that the FRQ's were done with intent and honesty.

Association Comments:

I think that your reflection is very insightful and clearly shows the learning you have gained from doing the FRQs. The fact that you had most of the elements from the FRQs in your project is also a great demonstrator of the power of PBL as an educational method. For some of your associations have future plans and not concrete connections from the present which I think can be worked on. For example you could have associated the 2D array with the Map that is used in making the person database. For your FRQ 3 response, I understand that SparseArrays are pretty uncommon (I did not use one either), but you could have still related the problem to Methods and Control Structures. However, I do appreciate the inclusion of how you could include SparseArrays specifically. I would like to further highlight your future plans, as writing out your next steps is an excellent way to solidify learning and prove that what you did was actually meaningful.

Association Score:

Overall, I would give you a 3.6/3.6 for your FRQ Association.