What is inline class in Kotlin and when do we need one? Provide an example. What is inline class in Kotlin and when do we need one? Provide an example. Senior Answer Sometimes it is necessary for business logic to create a wrapper around some type. However, it introduces runtime overhead due to additional heap allocations. Moreover, if the wrapped type is primitive, the performance hit is terrible, because primitive types are usually heavily optimized by the runtime. Inline classes provide us with a way to wrap a type, thus adding functionality and creating a new type by itself. As opposed to regular (non-inlined) wrappers, they will benefit from improved performance. This happens because the data is inlined into its usages, and object instantiation is skipped in the resulting compiled code. inline class Name ( val s : String ) { val length : Int get ( ) = s . length fun greet ( ) { println ( "Hello, $s " ) } } fun ma...
When you say your app works offline… does it really? A surprising number of Android developers proudly add “offline-first” to their app descriptions. And sure, the app opens without internet. Maybe it even loads a few screens. But dig a little deeper and it becomes clear: most offline-first implementations fall apart fast. Why? Because building an offline-first experience isn’t about just storing data locally. It’s about doing it intentionally , with the right structure, cleanup, and flow. And the culprit behind most of the silent issues? Room Database. Not because Room is bad — but because it's misunderstood. Let’s walk through some of the most common mistakes developers make when using Room in offline-first apps — and what to do instead. Mistake 1: Saving the Entire API Response into Room Many devs take the raw JSON response from their API and store it directly into Room entities — every field, every nested object, even things the app never uses. Why it’s a probl...
Tame large files and streamline your development workflow with Git Large File Storage (LFS) If you're an Android developer building feature-rich apps with stunning graphics, on-device machine learning, or immersive media — chances are you've bumped into Git’s limitations. From high-res images and videos to .tflite models and APKs, large files can seriously slow down your Git repo, mess with version control, and frustrate your team. That’s where Git Large File Storage (LFS) comes in. In this post, you'll learn how Git LFS helps Android developers manage large assets more efficiently, avoid Git pitfalls, and deliver faster, cleaner projects. Why Android Projects Need Git LFS Modern Android apps aren’t just about code — they’re rich experiences powered by assets: Images and animations for splash screens, UI elements, and AR Audio and video files for e-learning, podcasts, or games Machine learning models for features like face detection or text translatio...
Comments
Post a Comment