sheerlox

sheerlox

Looking for feedback on a little project I've made

Hello Elixir community!

I gave a few programming courses in a university a few months ago, and found myself with ~ 250 student projects to grade (from two assignments, introduction to Git & unit testing in Java).

So I jumped on the occasion to get my hands dirty with BEAM processes in the process! Thought it would be a pretty useful application of concurrency and fault-tolerance.

Since this is my first time using GenServer, Task and Supervisor/DynamicSupervisor, I would greatly appreciate any feedback you could make!

It does work very well, but I’m sure there is room for improvement, and I might even have made big mistakes.

You can find the project here: GitHub - sheerlox/auto_grader: An automatic assignments grading program written in Elixir · GitHub.

The readme contains my initial thought process and (ignorant) first design draft.

I’ve also published ExDocs on GH pages which contain the actual up-to-date documentation on how this thing works.

Thanks in advance :folded_hands:

Most Liked

andyleclair

andyleclair

I took a peruse through the code, and my biggest suggestion would be to just use Task and Task.Supervisor instead of GenServer, which would probably clean the code up a bit (Task.Supervisor is a DynamicSupervisor!) You could also use PartitionSupervisor with it, but I don’t think invoking the supervisor will be your bottleneck if you only have 250-ish tasks.

All in all, nice job! We had some code at my job that looked pretty similar to this running an automated integration test suite against prod

D4no0

D4no0

Everything is a process including supervisors, their only difference is that they catch exits from their child processes and restarts them, you can decide whether your topology makes sense.

andyleclair

andyleclair

I also thought using a TaskSupervisor inside a Task would be bad practice. Do you think it’s okay to do this, or could it lead to some issues?

I’m not sure what you mean? Your code can call code in another module at any time, nothing is really “special”.

I think once you start adding a few more tests, you’ll find the parts of this program that could be abstracted a bit, but as far as the code goes, it really is great, for your first shot at a “real OTP program” you’ve done a great job.

There are a few nitpicks I’d say, like rather than cast()-ing to yourself here, I’d use the {:continue, ...} return from init: auto_grader/lib/auto_grader.ex at dev · sheerlox/auto_grader · GitHub

You’re also doing a lot to store the parent pid, then send a message back when processing is done, whereas you could use the Task abstraction and just return the value.

If you’re writing use GenServer, restart: :temporary you may instead want a module that use Task instead.

Last Post!

sheerlox

sheerlox

Before starting this project I thought the TaskSupervisor would be started in my GenServer SubmissionRunner, so that didn’t sound like a good idea to make that module a simple/fragile Task.

I didn’t yet realize at that time the TaskSupervisor is actually started in the application tree (which makes total sense lol). I guess my doubts were based on that false assumption.

I clearly see the benefits of what you’ve pointed, I’ll try to integrate that soon (for science, because I already turned in this year’s grades).

Thanks a lot for the insights!

Where Next?

Popular in Discussions Top

scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
restack_oslo
Hello, Please pardon me for any faux paux. I am 46 and this is my first time on a forum of any kind. I wanted to to get answers from tho...
New
pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
crispinb
On reading dhh’s latest The One Person Framework it strikes me that Phoenix with LiveView is already pretty much this. However, never hav...
New
matthias_toepp
I’d love to hear what people think about Wisp, the new Gleam web framework started by Gleam’s primary creator Louis Pilfold. Gleam, alon...
New

Other popular topics Top

greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement