I told my boss I had an idea for a program that could improve efficiency across much of the business, and he let me build it on company time. In the long term, he wanted to be able to sell it to other companies. However, the program never got implemented due to personnel mismanagement, and I’d rather be able to post it on my github under a free licence so I can use it as a resume item, and at least someone would have the chance to actually use it. It’s all still in my head, and I could write it again if I wanted. If I do, is it illegal to publish it? What if I write it in a different language? Do I need to change the variable names? I did plenty of research and planning on company time to build it, and it’s not like I can research it again, it’s all still in my head.
If you implement it from fresh then it is a new program. What matters is what your contract says about what you produce - some contracts pay claim to anything you make even outside of working hours.
Also if you rewrite it, while technically it is a fresh project if there are substantial similarities in how you implement it there could be an argument made that you have reused code that belongs to the company. Even if that is technical false it could be something you’d have to defend sometime in the future. As others have said, implementing the program in a different language and using a different methodology wherever possible should help protect against that.
I think the advice others have given that you should review your contract with a lawyer is sound even if this will be FOSS. It’s mainly about ensuring you don’t inadvertently open yourself to potential legal repercussions down the line, even if your employers at the moment seem benign. If you do work for a company that lays claim to everything you produce even in your off hours then I would strongly recommend you consider leaving or an exit plan, particularly if you are the sort of person who would be working on your own projects for fun or even your own business ventures.
The problem is I learned how to write good code at university and I used what I learned to inform the software architecture. I could write garbage that gets the same job done but isn’t maintainable, except for the fact that I want to show this off as a display of my skill. I already did the best I could do on the company clock. If I do the best I can do again, it’ll be the same. I can’t make significant changes outside of language, variables, and dependencies, because then it wouldn’t be as good. The structure I made for the company is simply good design. I don’t remember every detail of the structure, but if I tried to rebuild it I’d get the same result. This is a problem with a correct answer.