Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8873055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:22:13+00:00 2026-06-14T18:22:13+00:00

Generally speaking, should one strive to align a class’s dependencies with its imports? For

  • 0

Generally speaking, should one strive to align a class’s dependencies with its imports?

For example, should one generally avoid doing something like this:

Bar.java:

import com.somepackage.Foo;
import com.somepackage.Baz;

public Bar(Foo foo) {...}

public void doSomething(Baz baz) {...}

Baz.java:

import com.somepackage.Bar;

public Baz(Bar bar) {...}

//etc...

Basically, Bar.java imports/uses/works with something that has it as a dependency, which seems odd.
Although, I’m not sure if classes using their dependents necessarily constitutes some sort of smell (i.e., compile-time dependencies do not line up with run-time dependencies, hinting that some refactoring should probably be done…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:22:14+00:00Added an answer on June 14, 2026 at 6:22 pm

    I think this is a design smell. Can you extract a third class that resolves the cyclic dependency? Should one direction of the dependency be decoupled with an interface?

    Without details of how the classes depend on each other it will be hard to be more specific.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Generally speaking, a common VB.NET class should look like the following: Public Class MyClassName
Effective Java: Item 6: Eliminate obsolete object references. Generally speaking, whenever a class manages
Generally speaking, should you do any Browser/Header Caching for dynamic PHP pages? If so,
Generally speaking, individual JavaScript files that a page uses should be combined into a
Speaking generally, is the caller that should guarantee to pass well-formed data to the
Generally speaking, the SQL queries that I write return unformatted data and I leave
Generally speaking, when given a cookie that has no expiration period, modern browsers will
Generally speaking, I am very happy with the changes in Xcode 3.2. However, there
Generally speaking, what are your recommendations on this? Currently takes close to 10 minutes
Generally speaking, for combining a lot of data is it better to use a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.