{"id":20365018,"url":"https://github.com/h3ar7b3a7/sf-assignment","last_synced_at":"2026-02-23T08:04:28.420Z","repository":{"id":136744773,"uuid":"311634891","full_name":"H3AR7B3A7/SF-Assignment","owner":"H3AR7B3A7","description":"As preparation for a group assessment, we were asked to provide a solution in pseudocode for a business problem.","archived":false,"fork":false,"pushed_at":"2020-11-25T12:44:22.000Z","size":731,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-25T19:43:12.044Z","etag":null,"topics":["pseudocode"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/H3AR7B3A7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-10T11:18:14.000Z","updated_at":"2020-11-25T12:44:25.000Z","dependencies_parsed_at":"2023-07-14T12:46:09.416Z","dependency_job_id":null,"html_url":"https://github.com/H3AR7B3A7/SF-Assignment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/H3AR7B3A7/SF-Assignment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H3AR7B3A7%2FSF-Assignment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H3AR7B3A7%2FSF-Assignment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H3AR7B3A7%2FSF-Assignment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H3AR7B3A7%2FSF-Assignment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/H3AR7B3A7","download_url":"https://codeload.github.com/H3AR7B3A7/SF-Assignment/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H3AR7B3A7%2FSF-Assignment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29739770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pseudocode"],"created_at":"2024-11-15T00:14:55.446Z","updated_at":"2026-02-23T08:04:28.403Z","avatar_url":"https://github.com/H3AR7B3A7.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pseudo Code Assignment\nThe handout can be found [here](https://github.com/H3AR7B3A7/SF-Assignment/blob/master/assignment-handout.pdf).  \nThere were two assignment extensions as well: [1](https://github.com/H3AR7B3A7/SF-Assignment/blob/master/extension-1-handout.pdf) and [2](https://github.com/H3AR7B3A7/SF-Assignment/blob/master/extension-2-handout.pdf).\n\n### Preface\nTo keep it simple we will take a look at a *single thread solution*. \nThen we will try to see what can be done to optimize the execution using multiple threads.\nFor brevity, we will just list some possibilities.\n\n## Single thread\nGiven a growing list of mails (listOfMails):\n\n    // To prevent data loss on power outage or shut downs,\n    // we can fetch these from 'csv' (or any table/file we write to)\n    // before the 'infinite' loop is started. \n    // (A reset could be asked through one of the args as a boolean.)\n    \n    recruitment = 0\n    spam = 0\n    sales = 0\n    reception = 0\n    \n    spamReferenceList = null\n    duplicate = 0\n    \n    get arg0 (reset): [default false]\n    if arg0 = false\n        recruitment = Read from CSV/file\n        spam = Read from CSV/file\n        sales = Read from CSV/file\n        reception = Read from CSV/file\n        duplicate = Read from CSV/file\n        \n    get arg1 (interval): [default 10]\n        intervalInMin = INPUT(\"Interval in minutes?\")\n    \n    WHILE liveSorting\n        get listOfMails\n        listOfMails -\u003e stream\n            if listOfMails != null\n                FOREACH mail of listOfMails\n                    // Using Apache commons string utils 'containsIgnorCase\n                    IF contains \"CV\" (~ title / body / attachment ???)\n                        forward to \"recruitment@parkshark.com\"\n                        recruitment++\n                    IF contains \"sales\" (~)\n                        forward to \"sales@parkshark.com\"\n                        sales++\n                    IF contains \"Promo\" OR contains \"advertising\" (~)\n                        IF NOT in spamReferenceList\n                            forward to \"spam@parkshark.com\"\n                            spam++\n                            add to spamReferenceList\n                        ELSE \n                            duplicate++\n                    ELSE \n                        // devide work among 2 people (can use a modulus and switch case for more people)\n                        if reception is even   \n                            forward to \"reception@parkshark.com\"\n                            reception++\n                        else \n                            forward to \"jobstudent@parkshark.com\"\n                            reception++\n                    delete mail (* in info@parkshark mailbox)\n            else\n                liveSorting = false     // To stop program when there are no more new mails,\n                                        // but having the program sleep for some time would make\n                                        // more sense. This way it doesn't need to be restarted.\n                // Execute some extra code before shut down\n        print # of mails\n        sleep (intervalInMin toMillis)\n        \n    getListOfMails\n        listOfMails = (List) GET someApi // The single most simplified line in this writing\n        return listOfMails\n        \n    deleteMail\n        DELETE someApi\n        \n    print # of mails\n        total = recruitment + spam + sales + reception\n        print: total, recruitment, spam, sales, reception\n        // Can print to csv file to save data \n        // This csv can be consumed by some other code and do more calc by adding collumns\n        // For example (current - previous) for data on 1 loop\n        \n    print # of mails including duplicates\n        total = recruitment + spam + sales + reception + duplicates\n        print: total, recruitment, spam + duplicates, sales, reception\n\n## Multiple threads\nThings we could try to optimize:\n- Use a **parallelStream** instead\n  - List of mails has to be big enough to improve execution speed\n- Introduce a **thread pool** and pass what comes after FOREACH to executors\n- Have **different threads each take a list**, then filter for containing a string before FOREACH\n  - There would be no future issues around the order in which the checks happen\n  - Some lists could be made to have more / less importance\n\n## Questions for 'Park Shark'\n- Where does the list of mails come from? (We only have the address so far.)\n- What is the average amount of mails received in the mailbox?\n- What are the preferences regarding the interval to check the mailbox?\n  - What should be the frequency?\n  - Should it be changeable?\n- Where will this program be running?\n  - Should this program have an own interface? \n  - Or will it be integrated and run with command line arguments?\n- ...\n\n---\n\u003cdiv align=\"right\"\u003e-- Steven D'Hondt\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh3ar7b3a7%2Fsf-assignment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh3ar7b3a7%2Fsf-assignment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh3ar7b3a7%2Fsf-assignment/lists"}