ppyordanov / Dynamic-Noise-and-Pollution-Map

A dynamically generated University of Glasgow noise and pollution campus map via the innovative Smart Citizen Kit developed in Barcelona, Spain by FabLab.
0 stars 0 forks source link

Models toString() Implementation #34

Closed ppyordanov closed 9 years ago

ppyordanov commented 9 years ago

Models currently have stubs for toString(), but the method has not been implemented. It will be used for model manipulation feedback in the console during runtime by using a console logger.

At the moment logging is served by _SLF4J_, a Java logging facade: http://www.slf4j.org/ .

ppyordanov commented 9 years ago

toString() methods have been implemented for all of the model classes in use (DataReading, Route, Device) using a StringBulder to improve execution speed. It displays object class as well as all of the attribute values for convenient referencing. The method is extensively used on the server for process logging and paired with SLF4J has been significantly helpful for identifying bugs and code sections that need refactoring:

logging

Below is the skeleton function structure (following the facade pattern):

    @Override
    public String toString() {

        StringBuilder string = new StringBuilder();
        String newLine = System.getProperty("line.separator");

        string.append(this.getClass().getName() + " Object {" + newLine);
        string.append("id: " + id + newLine);
        //model attributes
        ..

        return string.toString();

    }
ppyordanov commented 9 years ago

This task has been completed and can be closed now.