Skip to content

mra9776/interview-task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

notes

  • Spend time writing following project was about 1.5 hour, without any AI help.

  • I wonder how fast it could be done using AI tools with following strategies:

    1. fully rely on, starting explaining APIs and requirements. (with tools like firebase.studio or Cursor AI)

      • let the AI split the task, and figure out each part.
    2. Splitting and planning would be done by me. writing each class/method by AI. (with llms such as deepseek, chatgpt, ...)

      • using bite sized problems in order to let AI use less contexts for each problem, allowing me to refine each unit in a better way.
    3. Using AI for generating tests. (copilot, ...)

  • jdk15 issue

Tools and env which used:

  • IDE and tools:
    • IntelliJ IDEA 2024.3.5
    • Spring Initializer
  • Env:
    • Linux Ubuntu 22.04

API:

  • Abstraction (Interface segregation)

    • Of course, we can create an interface for each service and implements them, but due to limited scope of this task I consider it an overkill.
    • And also testing is simple yet. Almost everything can be done with simple mocking.
    • So I'm gonna postpone this matter, unless there is actual second implementation of services, or testing gets hard.
  • SecondMethod:

    • Is it Ok to serve stale data?
      • For the sake of simplicity we don't allow that.
      • however it's not too hard to do that. instead of simply rw.lock() we can rw.tryLock()
    • File lock machanism on diff platforms (win/linux)
      • .lock via posix(?) way
    • consistency upon whole file:
      • Well Because we're serving data by single key each time so it doesn't really matter but it's simple.
  • ThirdMethod:

    • Implementations:
      1. simple read and write with locks: not performant: writeValueNaive
      2. cache last read values then update and flush it: doesn't consider external changes
      3. cache values, monitor for changes, invalid cache upon external change, then update and flush: looks good yet.
      4. enqueue writes, try to commit after we got the lock.
    • Filesystem sync and flushing considerations?

Testing:

  • I just wrote simple tests for SecondService.
  • And also generally I'm avoiding Tests which needs Spring Contexts. They're heavy, running is time-consuming, and sometimes messy.
  • Tests I didn't write:
    • Services: Tests for each: todo
    • Controllers: WebMvcTest: No need yet.
    • Integration tests: postponed,

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published