Is it a bad thinks to use a lot object instead of ...
# getting-started
f
Is it a bad thinks to use a lot object instead of classes?
f
If the objects are related, you can bundle them in a class. Would be more structured, isn't it?
f
mmmm... for exemple I have a Vertx Verticle that use a service and a manager
the service and the manager are services
they are like utils classes
for example :
Copy code
package fstn.vertxFlow.config.manager

import io.vertx.rxjava.core.Vertx
import io.vertx.rxjava.core.buffer.Buffer
import rx.Observable


/**
 * Use to read or write bpmn flow file
 * @author fstn
 */
class BpmnManager {

    fun get(flowName:String): Observable<Buffer> {
        return Vertx.vertx().fileSystem()
                .rxReadFile(“$flowName.bpmn”)
                .doOnError { throw UnableToReadConfigurationException(flowName) }
                .toObservable()
    }

    fun set(flowName:String,flowContent:String): Observable<Void> {
        return Vertx.vertx().fileSystem()
                .rxWriteFile(“$flowName.bpmn”, Buffer.buffer(flowContent))
                .doOnError { throw UnableToWriteConfigurationException(flowName) }
                .toObservable()
    }

    class UnableToWriteConfigurationException(flowName: String) : RuntimeException(flowName)
    class UnableToReadConfigurationException(flowName: String) : RuntimeException(flowName)
}
f
am not familiar with rx 😅
😅 1
f
the get return the content of the file
and the set write into the file
should I use a class or an object ?
or a companion object
s
Personally I think you're fine using object - a class with companion would be overkill for something like this
alternatively you could just use a bunch of package-scoped functions, as there doesn't seem to be any persisted state here
f
yes there is no persistent data
but Intellij doesn’t import automaticaly package of function
so it’s very boring
that’s why I prefere to use classes or objects 😂
s
it should - it works for me
f
Am I wrong?
Mine doesn’t want to
s
strange
i guess the function names are too short for the intellisense to kick in
I use slightly longer names, and the autocoplete starts suggesting them
f
Maybe 😉