riswux / VisualNovel-1

0 stars 0 forks source link

Speculative Generality #8

Open riswux opened 1 year ago

riswux commented 1 year ago
Example 1

```kotlin // Define a data class to represent a single record data class Record(val position: String, val input: String) // Keep track of all records in a list val records = mutableListOf() val gson = Gson() val json = gson.toJson(records) ``` ### Description of the deficiency The code defines a data class Record to represent a single record, creates an empty mutable list records to store multiple records, and then converts the records list to JSON using the Gson library. ### Why is this code bad? What principles does it violate? What can the existence of such code lead to? The code violates the principle of YAGNI (You Ain't Gonna Need It), which suggests avoiding adding functionality or components that are not currently needed. It adds the complexity of maintaining an empty list and converting it to JSON, without any demonstrated requirement. The existence of such code can lead to confusion, unnecessary maintenance, and decreased code clarity. This flaw could appear due to speculative thinking or an attempt to anticipate future

LidiaIvanova commented 1 year ago

0,5