The table of two values, Behaviour and Structure!
Is it more important for the software system to work or is it more important to be easy to change? If you ask the business managers they will say work is more important, some developers also go along with this attitude but that’s the wrong attitude.
Why the wrong attitude?
- If you give me a program that works perfectly but impossible to change, it means it won’t work when the requirements change.
- If you give me a program that does not work but easy to change, it means I can make the change to make it work.
If you’re a programmer with the attitude (1.) then one day your system will reach to the point where the change will be impractical (cost of change will be unaffordably high).
Eisenhower said, I have two kinds of problems, the urgent and the important, where the urgent are not important and the important is never urgent.
when it comes to software, The first value of software is behavior, is urgent but not always important. The second value is architecture, is important but never urgent. Of course, some things are not urgent and not important.
- Urgent and important
- Not urgent and important
- Urgent and not important
- Not urgent and not important.
Mistakes that business managers and developer make is to elevate items in position 3 to 1. It means they always fail to separate those features that are urgent but not important from those features that are really urgent and important and this failure leads to ignoring the important architecture of the system in favor of the unimportant features of the system.
So if you are a software developer, you are hired to maintain the quality and structure of the system and only you know the importance of the architecture.
Thanks for reading it, if you want to read in more detail, buy “Clean Architecture by Robert C. Martin”
- Structs are the value type.
- Classes are the reference type.
- Properties of a constant instance of the struct are immutable because struct’s instance own the whole object and by declaring it as a constant means the whole object itself will be immutable.
- Properties of a constant instance of the class are mutable as class’s instance owns the object’s reference thus by declaring it as a constant only means that the further reference assignment can’t be done.
- Structs are blessed with default member-wise initializer but classes are not.
- Structs are preferable when they are small and copyable.
- With Structs, there is much less need to worry about memory leaks or multiple threads racing to access/modify a single instance of a variable.
- Since struct instances are allocated on the stack, and class instances are allocated on the heap, structs can sometimes be drastically faster (but it still depends on how many values you’re storing and the size/structure.)
- In a multi-threaded environment, for instance, with a database connection that’s opened in a different thread, structs are safer. They can be copied from one thread to another thread, without running the risk of a race condition or deadlock. Classes do not have this inherent safety unless they’re deliberately made thread-safe.
Thanks a lot for reading it.
“Today is all about Software,” Apple CEO Tim said as he took the stage at WWDC 2018.
It all started with statistics.
- 20 million iOS developers
- 500 million weekly app store visits
- 81% using iOS 11 where only 8% using latest Android
- Developers earned 100 million through App Store
- New iOS 12 will be released as a free update, every model back to the 5S will get a performance boost.
- ARKit, second generation, which included a lot of cool updates, most interesting is the ability for multiple users to observe and interact with the same environment from different angles.
- Apple Screen time, now iOS 12 will tell you how much time you’re spending with your iPhone and which are the apps.
- Do not disturb a lot of improvements, while you are sleeping will hide the notification, one step one time notifications.
- Photos, with iOS 12 they have revamped it. Allowing more search options driven by AI, share the photos through iMessage.
- Siri, it’s handling 10 billion requests per month and now Apple is allowing you to interact with it more, create shortcuts to trigger app features.
- Animojis, more personal now. It’s super accurate, face-tracking and tongue tracking capabilities. Surely it will feel you very familiar.
- Group FaceTime, now chat with 32 people at once with emoji, sticker, and other effects support.
iOS Apps updates
- Stocks, new UI with better performance
- Apple News app.
- Apple iBooks getting a redesign and a new name.
- Voice Memos, iPad getting it for the first time and recording will be now synced to iCloud.
So far biggest functions of the Apple iWatch is fitness, now Apple adding more components which let you challenge your friends.
- Automatic workout detection using your heart-beats(once you stop working out your heart rate decreases, so it will automatically stop).
- Walkie-Talkie, Texting/phone are tough using watch screen so Apple added an instant audio messaging app called walkie-talkie (uses the wifi or cellular to interact with other devices).
- Siri on Watch, allow third-party apps to show you more information. Now just lift your wrist and start talking it means no more “Hey Siri”.
- Podcasts app is coming on your wrist.
How to use Swift classes into Objective Code when you have multiple targets.
For using Swift classes in Objective-C Code when you have one target in your app. We generally need to and
import TargetName-Swift.h next to add support in your Swift file you need to inherit if from
NSObject or use
What if you have multiple targets in your codebase? As you cannot import,
TargetNameB-Swift.h etc. In that case, you can tell the compiler that not to create Swift module specific to target change it to project name because the project will be same and unique.
For achieving this select your every target, Build Settings and change the build configuration.
Objective-C Generated Interface Header Name —> replace $(SWIFT_MODULE_NAME)-Swift.h that is specific to the each target, with $(PROJECT_NAME)-Swift.h
Later import PROJECT_NAME-Swift.h in your Objective C code to make use of your Swift code.
Lots of developers consulted with me regarding on how to use storyboard with too many team members like when you have 20 developers on your team? So I have collected my thoughts on that today. I have used Storyboard as well as XIB so here are my thoughts on both.
- Storyboards are the really nice way to see complete application flow without running into Simulator, you can see the screen flow and the navigation between them, it’s one of key thing that makes your application architecture better.
- For a larger team of multiple developers it’s really difficult to use the same storyboard because at the end it’s XML file so really very hard to merge and you will end up with a lot of conflicts, So I have noted, a lot of developers suggest XIB here but I don’t see any reason why they choose XIB and I think the best idea is the divide the complete application in different storyboard according to their use-case, that is the first activity I always do, divide complete app into as much as possible storyboard you can (but it’s not like 1 storyboard for 1 ViewController) and use storyboard reference to connect them.
- I worked in rapid prototype development (deliver the complete application in 15-20 days, developed POC in 7 days) so the biggest benefit that I earned from storyboard is Mock-up, I can create complete app mock-up without writing a single line of code and really easy to manage the transition between views.
- Few issues that I feel with the storyboard is, it fails at runtime means if you made a mistake with segue name, the class doesn’t exist etc. Yes, it gives issue at compile as well only if you didn’t merge it properly (merge conflicts with XML tags).
- Using Storyboard, no need to run your app on the different simulator to verify the UI, it gives you fantastic feature called preview (Click on the Assistant editor, select your storyboard, choose automation to preview).
- Developers say it’s harder to reuse the code in storyboard but my opinion is, first think and implement, try to use mix approach with the storyboard, XIB (wherever requires use XIB to make it reusable on different storyboards).
- Yes, storyboard creates an issue when you create one in Xcode 8 and try to open it in Xcode 7 but lots of developers already raised this concern with Apple so hopefully, we will hear something from Apple soon.
Thank you for reading! Please do share your thoughts if any.
Why do we need to create frameworks? because it has three major purposes mentioned below and also you can share your code with your team, other developer or iOS community.
- Code encapsulation
- Code modularity
- Code reuse
Let’s create the iOS framework.
Now just give some meta-data about your framework like name, organization, identifier etc (I hope you’re already aware of it).
We’re good to go till now. Just add the files that you want to keep within your framework.
Build the framework project to make sure that you get build succeeded with no build warnings or errors.
Things that you need to take care.
- Make sure to check Copy items if needed, so that the files actually copy into the new project instead of just adding a reference. Frameworks need their own code, not references, to be independent.
- Double-check that each of the files has Target Membership in ThreeRingControl to make sure they appear in the final framework. You can see this in the File Inspector for each file.
- Double-check the access modifiers, while creating framework access modifiers plays very important roles.
- if you’re creating Swift framework make sure you’re extending classes from NSObject otherwise it won’t reflect once you will import the framework.
Thanks for reading.
Recent blog: SOLID vs STUPID
STUPID principles and yes this may hurt your feeling but yes if you are following this you are writing stupid code.
Well known design pattern, but mostly understood one as well. Like me, people are also fighting with Singleton syndrome. In that case, whenever we create a class we create it Singleton but why? That is definability not cool. Singleton also considered anti-patterns. We should think and avoid if possible because the program using Singleton are hard to test because of global state, with the global state they hide their dependencies.
Avoiding static things is important to avoid tight coupling. If it’s there then making a change in one module requires to changes another module too. Now it’s really difficult to reuse and difficult to test.
Testing is not hard, what you think? We don’t write test case may be because we don’t have the time or the code we are writing is bad because of tight coupling?
One of my favorite quote from Donald Knuth, premature is the root of all evil. There are only cost and no benefits. Actually optimised code is much complex as compared to just writing a loop.
That’s what I like most and I try to follow as much as possible. Name of your class, variables or methods should be clear because at the end of the day human is only going to read because programming languages are for human not for computers, computers can understand 0 or 1 very well.
That’s bad. Writing same code again and again so don’t repeat yourself, keep it simple and strong. Write Code only once.
Thank you for reading the quick introduction of STUPID principles, next will be SOLID principles.