Giter Club home page Giter Club logo

Comments (6)

fdw avatar fdw commented on September 21, 2024

As you can see, I already gave unit tests a whirl with this branch. However, most of the other code has a very high complexity that makes it nearly impossible to write good unit tests. Do you think the productive code should be simplified so that we can test it, @adrcotfas ?

from goodtime.

adrcotfas avatar adrcotfas commented on September 21, 2024

Of course, simplifying the code is always welcome.

from goodtime.

fdw avatar fdw commented on September 21, 2024

Hi,
it's been quite some time since I opened this, so I wanted to give you a heads-up that I'm still working on this, and a quick update:
All of the logic regarding the interface is in the TimerActivity, so I think testing it is very important. However it's also not easy, because tests need to test both the behavior ("is the timer running?") and the UI ("Is the button now visible?"). To get a better grip on this, I tried to split the class according to the standard design pattern for Android, Model-View-Presenter, and have both an TimerActivity and a TimerPresenter. Also, since the activity is both for the sidebar and the timer UI itself, I wanted to create a TimerFragment containing only the timer UI. In theory, this means that each class has a single, well-defined responsibility, and testing should be much easier (the TimerPresenter needs no Android-specific framework, for example, and the TimerFragment should have no logic tests).
To ease the pain of dependencies, I wanted to use Dagger 2 which has no runtime cost. All of this seems to be best practice for Android apps, but I'm not sure - what do you think of this?

I tried to build a proof of concept for these ideas with some dirty refactorings, but it's not that easy - mostly because I don't have any experience with Dagger. While most of the separate classes look okay and have sane interfaces, there is still a circular dependency that I can't seem to resolve. I will keep trying to work this out, but I wanted your opinion on the whole design before I put more work into it. If you're interested in the code, I can push what I have.

Additionally, I've started this proof of concept more than a month ago, so I missed all your changes since then :( But I hope that a working prototype can be extended and polished quite easily.

from goodtime.

adrcotfas avatar adrcotfas commented on September 21, 2024

Hi,
You're plan sounds good and I look forward to see what you manage to refactor.
I don't have any experience with Dagger either but if you need any help, please let me know! You could split the work in small tasks in the issue page if you want.
In the past month the changes weren't too numerous I would say and I hope that they will not entangle you :)

from goodtime.

fdw avatar fdw commented on September 21, 2024

Thanks for your kind words and support! :)

I pushed the non-working proof of concept to a separate branch so you can have a look at it. Please remember that it is not good code, but so much copy-and-pasting and just generally prodding to test if it might work!

I think the best way forward would be to start the redesign all over again, but with much smaller and better defined steps - trying to do everything at once was a bad idea.
As you can see here, I rebased onto your latest changes and then moved some classes around to have a clearer package structure. From this I'm then going to implement a presenter for TimerActivity. Only when this is working should we start to separate the TimerFragment. How does this sound to you?

from goodtime.

adrcotfas avatar adrcotfas commented on September 21, 2024

Sounds good!
I left some comments to your changes.
BTW, I see I forgot to merge some of my recent changes and hopefully they will not affect your new branch too much. I left an explanation of the change here: 0791fc1.
I will merge it now to have the current state of the app on master.

from goodtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.