phi

phi

Hi all,

I’m just getting back to learning Phoenix 1.7 after a small hiatus and I’m building a simple one-page site that connects to a Marketing Email API. Maybe I’m overthinking it, but I was wondering where one would go about placing an Elixir wrapper file for the API integration?

I was thinking it would just go in lib/hello/mailchimp.ex for example, or is there a better organization structure? Doesn’t really matter this specific small project, but was thinking for larger projects I could have many such files.

Thanks for any help!

Showing Posts 1 to 8

dimitarvp

dimitarvp

If you want to future-proof it a little then something like lib/third-party/<service>.ex is an okay way to go about it.

krasenyp

krasenyp

I second that. I keep seeing people being afraid of creating directories in lib/ and sometimes even reach for umbrella project.

dimitarvp

dimitarvp

Elixir being both (a) explicit and (b) giving freedom can really be paralyzing. Many people, myself from the past included, were being PTSD’d into submission by very opinionated frameworks.

whoiswentz

whoiswentz

I like to place all my third-party code inside lib/external/<service_name>/<feature>.ex

gregvaughn

gregvaughn

I’ll be the contrary voice. I would not create a subdirectory until it is needed :person_shrugging:
I’ve dealt with codebases that over time had all sorts of different opinions on how to organize the source code. I learned to fuzzy find a module by name in my preferred editor. I almost never even notice the directory structure when I’m coding.

It is important to understand that at runtime all modules are in one flat namespace. Runtime relationships between modules are much more important than where the source is on the filesystem. I think of it like code “in action” is runtime and code “at rest” is directories on the filesystem. Yes, some people want to use the filesystem to suggest those runtime relationships, and that’s admirable, but it also can become incorrect. The source of truth is the runtime.

dimitarvp

dimitarvp

Yeah same and I do agree with your stance, it’s just that as you said it’s basically an aesthetic suggestion for anybody else who doesn’t use fuzzy searching and/or people browsing the project from GitHub’s web UI.

Beyond those use cases the relative path of the module indeed has zero value.

phi

phi OP

I always appreciate the contrary opinions, and I do agree especially for smaller projects.

The one downside I see from working with other engineers is that for larger projects they might judge you for having many files in a flat structure (and possibly the same with people that look through the codebase looking to hire you, although one would hope code quality would weigh more heavily).

phi

phi OP

Agreed, especially coming from large monolithic Rails apps, I’ve noticed a lot of engineers prefer things set up very precisely, which now looking back, the PTSD from those experiences is probably why I posted the question to begin with :smiley:

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews