Skip to content

London | 25-SDC-Nov | Emiliano Uruena | Sprint 2 | LRU-cache Python#133

Open
Emilianouz wants to merge 2 commits intoCodeYourFuture:mainfrom
Emilianouz:Sprint-2-lru-cache
Open

London | 25-SDC-Nov | Emiliano Uruena | Sprint 2 | LRU-cache Python#133
Emilianouz wants to merge 2 commits intoCodeYourFuture:mainfrom
Emilianouz:Sprint-2-lru-cache

Conversation

@Emilianouz
Copy link

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Implement LRU Cache functionality.

@Emilianouz Emilianouz changed the title London | 25-SDC-Nov | Emiliano Uruena | Sprint 2 | LRU-cache London | 25-SDC-Nov | Emiliano Uruena | Sprint 2 | LRU-cache Python Feb 28, 2026
@Emilianouz Emilianouz added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 28, 2026
Copy link

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To better adhere to the Single-Responsibility Principle (SRP) from SOLID design principles,
it's preferable to implement the "doubly linked list" and the "LRU Cache" as separate classes, with the linked list used inside LruCache to manage ordering.
In fact, you can import your LinkedList class from the other exercise, and then store each key-value pairs as a tuple.

Alternatively, you can use OrderedDict directly within LruCache to maintain order.

Could you update your code using one of these approaches?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 2, 2026
@Emilianouz Emilianouz added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 4, 2026
@Emilianouz
Copy link
Author

To better adhere to the Single-Responsibility Principle (SRP) from SOLID design principles, it's preferable to implement the "doubly linked list" and the "LRU Cache" as separate classes, with the linked list used inside LruCache to manage ordering. In fact, you can import your LinkedList class from the other exercise, and then store each key-value pairs as a tuple.

Alternatively, you can use OrderedDict directly within LruCache to maintain order.

Could you update your code using one of these approaches?

I've implemented by storing key/value in a Node class. LMKWYT. Thank you.

Copy link

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is working.

Formatting is not quite consistent. e.g.

  • Line 63: no space after ', in parameter list
  • Line 62, 75: No space after #

You can install a formatter extension in VSCode and enable "Format on save" to keep all code formatted consistently automatically. (Note: Python formatter extension requires Python runtime to work in VSCode.)

Comment on lines +2 to +7
class Node:
def __init__(self, key, value):
self.key = key
self.value = value
self.previous = None
self.next = None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also just import the linked list class you implemented in the other exercise and then store key-value pair as a tuple.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants